feat(python): support nested reference for fts (#723)

https://github.com/lancedb/lance/issues/1739

Support nested field reference in full text search

---------

Co-authored-by: Will Jones <willjones127@gmail.com>
This commit is contained in:
Chang She
2023-12-20 12:28:53 -08:00
committed by GitHub
parent 371d2f979e
commit 7856a94d2c
2 changed files with 55 additions and 2 deletions

View File

@@ -43,7 +43,15 @@ def table(tmp_path) -> ldb.table.LanceTable:
for _ in range(100)
]
table = db.create_table(
"test", data=pd.DataFrame({"vector": vectors, "text": text, "text2": text})
"test",
data=pd.DataFrame(
{
"vector": vectors,
"text": text,
"text2": text,
"nested": [{"text": t} for t in text],
}
),
)
return table
@@ -89,3 +97,9 @@ def test_empty_rs(tmp_path, table, mocker):
mocker.patch("lancedb.fts.search_index", return_value=([], []))
df = table.search("puppy").limit(10).to_pandas()
assert len(df) == 0
def test_nested_schema(tmp_path, table):
table.create_fts_index("nested.text")
rs = table.search("puppy").limit(10).to_list()
assert len(rs) == 10