Skip to content

FTS on list of strings returns duplicate results #5887

Description

@wjones127
import pyarrow as pa
import lance

data = pa.Table.from_pydict(
    {
        "id": list(range(2)),
        "tags": [
            ["puppy dinosaur", "puppy", "puppy horse"],
            ["horse dinosaur", "horse", "puppy dinosaur"],
        ],   
    }
)
ds = lance.write_dataset(data, "memory://") # maybe an old data storage version?

ds.create_scalar_index("tags", index_type="INVERTED")

ds.to_table(full_text_query="puppy").to_pylist()
[{'id': 0, 'tags': ['puppy dinosaur', 'puppy', 'puppy horse'], '_score': 0.5282782912254333}, 
 {'id': 1, 'tags': ['horse dinosaur', 'horse', 'puppy dinosaur'], '_score': 0.40841686725616455},
 {'id': 0, 'tags': ['puppy dinosaur', 'puppy', 'puppy horse'], '_score': 0.40841686725616455}, 
 {'id': 0, 'tags': ['puppy dinosaur', 'puppy', 'puppy horse'], '_score': 0.40841686725616455}]

It's not particularly useful to get these duplicate results. Although they do that different scores and potential meanings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions