oramasearch/orama

Threshold set to 0 not working as expected

Closed this issue · 1 comments

Describe the bug

I am having trouble with understanding how threshold number works.
I have dataset like this:

[{model: 'Account', title: 'Orama'}]

when I am trying

const results = await search(db, {
term: "account orama",
threshold: 0,
});

this gives 0 results, but the documentation states that when that with threshold 0, the keywords can be found in different properties.
What is the correct behavior here?

To Reproduce

  1. init Orama with schema {model: string, title: string}
  2. insert data to Orama schema {model: 'Account', title: 'Orama'}
  3. query the data with term "account orama" and set the threshold to be 0 (or nothing as 0 is the default value for it).

Expected behavior

I expect to get 1 result based on documentation but I am getting 0 results

Environment Info

OS: MacOS
Node: 18.19.0
Orama: 2.1.0

Affected areas

Search

Additional context

No response

The following code works on main. We'll release it tomorrow

import { create, insert, search } from '@orama/orama';

const db = await create({
    schema: {
        model: 'string',
        title: 'string',
    } as const,
});
await insert(db, {model: 'Account', title: 'Orama'});
const results = await search(db, {
    term: "account orama",
    threshold: 0,
});

console.assert(results.count, 1)

Thanks for reporting the issue.