mirror of
https://github.com/qdrant/qdrant-client.git
synced 2026-08-02 16:10:59 -05:00
tests: Add more test cases
This commit is contained in:
@@ -309,7 +309,9 @@ class TestSimpleSearcher:
|
||||
limit=10,
|
||||
)
|
||||
|
||||
def dense_queries_rescore_filtered(self, client: QdrantBase, query_filter: models.Filter) -> Union[List[models.ScoredPoint], models.QueryResponse]:
|
||||
def dense_queries_prefetch_filtered(
|
||||
self, client: QdrantBase, query_filter: models.Filter
|
||||
) -> Union[List[models.ScoredPoint], models.QueryResponse]:
|
||||
return client.query_points(
|
||||
collection_name=COLLECTION_NAME,
|
||||
prefetch=[
|
||||
@@ -330,6 +332,54 @@ class TestSimpleSearcher:
|
||||
limit=10,
|
||||
)
|
||||
|
||||
def dense_queries_prefetch_score_threshold(
|
||||
self, client: QdrantBase
|
||||
) -> Union[List[models.ScoredPoint], models.QueryResponse]:
|
||||
return client.query_points(
|
||||
collection_name=COLLECTION_NAME,
|
||||
prefetch=[
|
||||
models.Prefetch(
|
||||
query=self.dense_vector_query_text, using="text", score_threshold=0.9
|
||||
),
|
||||
models.Prefetch(
|
||||
query=self.dense_vector_query_code,
|
||||
using="code",
|
||||
score_threshold=0.1,
|
||||
),
|
||||
],
|
||||
query=self.dense_vector_query_image,
|
||||
using="image",
|
||||
with_payload=True,
|
||||
limit=10,
|
||||
)
|
||||
|
||||
def dense_queries_prefetch_parametrized(
|
||||
self, client: QdrantBase, search_params: models.SearchParams
|
||||
) -> Union[List[models.ScoredPoint], models.QueryResponse]:
|
||||
return client.query_points(
|
||||
collection_name=COLLECTION_NAME,
|
||||
prefetch=[
|
||||
models.Prefetch(
|
||||
query=self.dense_vector_query_text, using="text", params=search_params
|
||||
),
|
||||
],
|
||||
query=self.dense_vector_query_image,
|
||||
using="image",
|
||||
with_payload=True,
|
||||
limit=10,
|
||||
)
|
||||
|
||||
def dense_queries_parametrized(
|
||||
self, client: QdrantBase, search_params: models.SearchParams
|
||||
) -> Union[List[models.ScoredPoint], models.QueryResponse]:
|
||||
return client.query_points(
|
||||
collection_name=COLLECTION_NAME,
|
||||
query=self.dense_vector_query_image,
|
||||
using="image",
|
||||
limit=10,
|
||||
search_params=search_params,
|
||||
)
|
||||
|
||||
def dense_queries_orderby(self, client: QdrantBase) -> List[models.ScoredPoint]:
|
||||
return client.query_points(
|
||||
collection_name=COLLECTION_NAME,
|
||||
@@ -572,7 +622,7 @@ def test_no_query_no_prefetch():
|
||||
compare_client_results(local_client, remote_client, searcher.no_query_no_prefetch)
|
||||
|
||||
|
||||
def test_filtered_prefetch():
|
||||
def test_dense_query_filtered_prefetch():
|
||||
fixture_points = generate_fixtures()
|
||||
|
||||
searcher = TestSimpleSearcher()
|
||||
@@ -587,13 +637,106 @@ def test_filtered_prefetch():
|
||||
query_filter = one_random_filter_please()
|
||||
try:
|
||||
compare_client_results(
|
||||
local_client, remote_client, searcher.dense_queries_rescore_filtered, query_filter=query_filter
|
||||
local_client,
|
||||
remote_client,
|
||||
searcher.dense_queries_prefetch_filtered,
|
||||
query_filter=query_filter,
|
||||
)
|
||||
except AssertionError as e:
|
||||
print(f"\nFailed with filter {query_filter}")
|
||||
raise e
|
||||
|
||||
|
||||
def test_dense_query_prefetch_score_threshold():
|
||||
fixture_points = generate_fixtures()
|
||||
|
||||
searcher = TestSimpleSearcher()
|
||||
|
||||
local_client = init_local()
|
||||
init_client(local_client, fixture_points)
|
||||
|
||||
remote_client = init_remote()
|
||||
init_client(remote_client, fixture_points)
|
||||
|
||||
compare_client_results(
|
||||
local_client, remote_client, searcher.dense_queries_prefetch_score_threshold
|
||||
)
|
||||
|
||||
|
||||
def test_dense_query_prefetch_parametrized():
|
||||
fixture_points = generate_fixtures()
|
||||
|
||||
searcher = TestSimpleSearcher()
|
||||
|
||||
local_client = init_local()
|
||||
init_client(local_client, fixture_points)
|
||||
|
||||
remote_client = init_remote()
|
||||
init_client(remote_client, fixture_points)
|
||||
|
||||
compare_client_results(
|
||||
local_client,
|
||||
remote_client,
|
||||
searcher.dense_queries_prefetch_parametrized,
|
||||
search_params={"exact": True},
|
||||
)
|
||||
compare_client_results(
|
||||
local_client,
|
||||
remote_client,
|
||||
searcher.dense_queries_prefetch_parametrized,
|
||||
search_params={"hnsw_ef": 128},
|
||||
)
|
||||
compare_client_results(
|
||||
local_client,
|
||||
remote_client,
|
||||
searcher.dense_queries_prefetch_parametrized,
|
||||
search_params={"indexed_only": True},
|
||||
)
|
||||
compare_client_results(
|
||||
local_client,
|
||||
remote_client,
|
||||
searcher.dense_queries_prefetch_parametrized,
|
||||
search_params={"quantization": {"ignore": True, "rescore": True, "oversampling": 2.0}},
|
||||
)
|
||||
|
||||
|
||||
def test_dense_query_parametrized():
|
||||
fixture_points = generate_fixtures()
|
||||
|
||||
searcher = TestSimpleSearcher()
|
||||
|
||||
local_client = init_local()
|
||||
init_client(local_client, fixture_points)
|
||||
|
||||
remote_client = init_remote()
|
||||
init_client(remote_client, fixture_points)
|
||||
|
||||
compare_client_results(
|
||||
local_client,
|
||||
remote_client,
|
||||
searcher.dense_queries_parametrized,
|
||||
search_params={"exact": True},
|
||||
)
|
||||
compare_client_results(
|
||||
local_client,
|
||||
remote_client,
|
||||
searcher.dense_queries_parametrized,
|
||||
search_params={"hnsw_ef": 128},
|
||||
)
|
||||
compare_client_results(
|
||||
local_client,
|
||||
remote_client,
|
||||
searcher.dense_queries_parametrized,
|
||||
search_params={"indexed_only": True},
|
||||
)
|
||||
compare_client_results(
|
||||
local_client,
|
||||
remote_client,
|
||||
searcher.dense_queries_parametrized,
|
||||
search_params={"quantization": {"ignore": True, "rescore": True, "oversampling": 2.0}},
|
||||
)
|
||||
|
||||
|
||||
def test_sparse_query():
|
||||
fixture_points = generate_sparse_fixtures()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user