Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full text search with limit seems to be giving incorrect answer in this sample case #3264

Closed
westonpace opened this issue Dec 17, 2024 · 0 comments · Fixed by #3284
Closed

Comments

@westonpace
Copy link
Contributor

In the below example we do a FTS on two strings. If we don't apply a limit (or set the limit to 2) then we can see the shorter string has a higher score (presumably because a higher percentage of words are contained in the match?). However, if we set the limit to 1 then we get the document with the lower score back.

import lance
import pyarrow as pa
import shutil

shutil.rmtree("/tmp/foo.lance", ignore_errors=True)

tab = pa.table({
    "text": ["this is some text", "this is some other text"]
})
ds = lance.write_dataset(tab, "/tmp/foo.lance")
ds.create_scalar_index("text", index_type="INVERTED")

print("Results with limit(1)")
print("---------------------")
print(ds.to_table(full_text_query="some text", limit=1))

print("Results with limit(2)")
print("---------------------")
print(ds.to_table(full_text_query="some text", limit=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants