oramasearch/orama

Weird issue with `tolerance` set to 1

remidewitte opened this issue · 2 comments

Describe the bug

When I search for an exact match, tolerance 1 gives wrong results.

To Reproduce

Given this :

const index = await create({
    schema: {
      libelle: 'string',
    }
  });

  await insertMultiple(index, [
    {libelle: 'ABRICOT MOELLEUX'},
    {libelle: 'MOELLEUX CHOC BIO'},
    {libelle: 'CREPE MOELLEUSE'},
    {libelle: 'OS MOELLE'},
  ]);

This one without tolerance gives accurate results :

  • ABRICOT MOELLEUX
  • MOELLEUX CHOC BIO
search(index, {
    term: 'moelleux',
})

This one with tolerance set to 1 gives only :

  • OS MOELLE
search(index, {
    term: 'moelleux',
    tolerance: 1,
})

With tolerance set to 2, I have all documents.

With tolerance set to 1 and term set to 'moelleu', I have accurate results.

Expected behavior

I expected 'moelleux' to give accurate results even if tolerance is set to 1, given that it is an exact match.

Environment Info

OS : MacOS
Node : v20.13.1
Orama : 2.0.21

Affected areas

Search

Additional context

No response

Hi @remidewitte,
Thanks for your patience. We think we identified the issue and provided a fix (#786), it will be released with v2.1.1.

Remember to play around with the threshold value to get the expected results: https://docs.orama.com/open-source/usage/search/threshold

Thanks