mirror of
https://github.com/lancedb/lancedb.git
synced 2026-05-16 11:30:41 +00:00
fix: add better check for empty results in hybrid search (#2252)
fixes: https://github.com/lancedb/lancedb/issues/2249
This commit is contained in:
@@ -368,6 +368,26 @@ def test_rrf_reranker_distance():
|
||||
assert score == fts_scores[rowid], "Score mismatch"
|
||||
assert found_match, "No results matched between hybrid and fts search"
|
||||
|
||||
# Test for empty fts results
|
||||
fts_results = (
|
||||
table.search("abcxyz" * 100, query_type="fts").with_row_id(True).to_list()
|
||||
)
|
||||
hybrid_results = (
|
||||
table.search(query_type="hybrid")
|
||||
.vector([0.0] * 32)
|
||||
.text("abcxyz" * 100)
|
||||
.with_row_id(True)
|
||||
.rerank(reranker)
|
||||
.to_list()
|
||||
)
|
||||
assert len(fts_results) == 0
|
||||
# confirm if _rowid, _score, _distance & _relevance_score are present in hybrid
|
||||
assert len(hybrid_results) > 0
|
||||
assert "_rowid" in hybrid_results[0]
|
||||
assert "_score" in hybrid_results[0]
|
||||
assert "_distance" in hybrid_results[0]
|
||||
assert "_relevance_score" in hybrid_results[0]
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
os.environ.get("COHERE_API_KEY") is None, reason="COHERE_API_KEY not set"
|
||||
|
||||
Reference in New Issue
Block a user