Skip to content

Commit 0d73899

Browse files
committed
deprecate: replace search with query points in test sparse search
1 parent 6ff22c9 commit 0d73899

File tree

1 file changed

+52
-51
lines changed

1 file changed

+52
-51
lines changed

tests/congruence_tests/test_sparse_search.py

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -31,115 +31,114 @@ def __init__(self):
3131
self.query_code = generate_random_sparse_vector(sparse_code_vector_size, density=0.1)
3232

3333
def simple_search_text(self, client: QdrantBase) -> list[models.ScoredPoint]:
34-
return client.search(
34+
return client.query_points(
3535
collection_name=COLLECTION_NAME,
36-
query_vector=NamedSparseVector(name="sparse-text", vector=self.query_text),
36+
using="sparse-text",
37+
query=self.query_text,
3738
with_payload=True,
3839
with_vectors=["sparse-text"],
3940
limit=10,
40-
)
41+
).points
4142

4243
def simple_search_image(self, client: QdrantBase) -> list[models.ScoredPoint]:
43-
return client.search(
44+
return client.query_points(
4445
collection_name=COLLECTION_NAME,
45-
query_vector=NamedSparseVector(name="sparse-image", vector=self.query_image),
46+
query=self.query_image,
47+
using="sparse-image",
4648
with_payload=True,
4749
with_vectors=["sparse-image"],
4850
limit=10,
49-
)
51+
).points
5052

5153
def simple_search_code(self, client: QdrantBase) -> list[models.ScoredPoint]:
52-
return client.search(
54+
return client.query_points(
5355
collection_name=COLLECTION_NAME,
54-
query_vector=NamedSparseVector(name="sparse-code", vector=self.query_code),
56+
using="sparse-code",
57+
query=self.query_code,
5558
with_payload=True,
5659
with_vectors=True,
5760
limit=10,
58-
)
61+
).points
5962

6063
def simple_search_text_offset(self, client: QdrantBase) -> list[models.ScoredPoint]:
61-
return client.search(
64+
return client.query_points(
6265
collection_name=COLLECTION_NAME,
63-
query_vector=NamedSparseVector(name="sparse-text", vector=self.query_text),
66+
query=self.query_text,
67+
using="sparse-text",
6468
with_payload=True,
6569
limit=10,
6670
offset=10,
67-
)
71+
).points
6872

6973
def search_score_threshold(self, client: QdrantBase) -> list[models.ScoredPoint]:
70-
res1 = client.search(
74+
res1 = client.query_points(
7175
collection_name=COLLECTION_NAME,
72-
query_vector=NamedSparseVector(name="sparse-text", vector=self.query_text),
76+
using="sparse-text",
77+
query=self.query_text,
7378
with_payload=True,
7479
limit=10,
7580
score_threshold=0.9,
76-
)
81+
).points
7782

78-
res2 = client.search(
83+
res2 = client.query_points(
7984
collection_name=COLLECTION_NAME,
80-
query_vector=NamedSparseVector(name="sparse-text", vector=self.query_text),
85+
using="sparse-text",
86+
query=self.query_text,
8187
with_payload=True,
8288
limit=10,
8389
score_threshold=0.95,
84-
)
90+
).points
8591

86-
res3 = client.search(
92+
res3 = client.query_points(
8793
collection_name=COLLECTION_NAME,
88-
query_vector=NamedSparseVector(name="sparse-text", vector=self.query_text),
94+
using="sparse-text",
95+
query=self.query_text,
8996
with_payload=True,
9097
limit=10,
9198
score_threshold=0.1,
92-
)
99+
).points
93100

94101
return res1 + res2 + res3
95102

96103
def simple_search_text_select_payload(self, client: QdrantBase) -> list[models.ScoredPoint]:
97-
return client.search(
104+
return client.query_points(
98105
collection_name=COLLECTION_NAME,
99-
query_vector=NamedSparseVector(name="sparse-text", vector=self.query_text),
106+
using="sparse-text",
107+
query=self.query_text,
100108
with_payload=["text_array", "nested.id"],
101109
limit=10,
102-
)
110+
).points
103111

104112
def search_payload_exclude(self, client: QdrantBase) -> list[models.ScoredPoint]:
105-
return client.search(
113+
return client.query_points(
106114
collection_name=COLLECTION_NAME,
107-
query_vector=NamedSparseVector(name="sparse-text", vector=self.query_text),
115+
using="sparse-text",
116+
query=self.query_text,
108117
with_payload=models.PayloadSelectorExclude(exclude=["text_array", "nested.id"]),
109118
limit=10,
110-
)
119+
).points
111120

112121
def simple_search_image_select_vector(self, client: QdrantBase) -> list[models.ScoredPoint]:
113-
return client.search(
122+
return client.query_points(
114123
collection_name=COLLECTION_NAME,
115-
query_vector=NamedSparseVector(name="sparse-image", vector=self.query_image),
124+
using="sparse-image",
125+
query=self.query_image,
116126
with_payload=False,
117127
with_vectors=["sparse-image", "sparse-code"],
118128
limit=10,
119-
)
129+
).points
120130

121131
def filter_search_text(
122132
self, client: QdrantBase, query_filter: models.Filter
123133
) -> list[models.ScoredPoint]:
124-
return client.search(
125-
collection_name=COLLECTION_NAME,
126-
query_vector=NamedSparseVector(name="sparse-text", vector=self.query_text),
127-
query_filter=query_filter,
128-
with_payload=True,
129-
limit=10,
130-
)
131-
132-
def filter_search_text_single(
133-
self, client: QdrantBase, query_filter: models.Filter
134-
) -> list[models.ScoredPoint]:
135-
return client.search(
134+
return client.query_points(
136135
collection_name=COLLECTION_NAME,
137-
query_vector=self.query_text, # why it is not a NamedSparseVector?
136+
using="sparse-text",
137+
query=self.query_text,
138138
query_filter=query_filter,
139139
with_payload=True,
140-
with_vectors=True,
141140
limit=10,
142-
)
141+
).points
143142

144143
def default_mmr_query(self, client: QdrantBase) -> models.QueryResponse:
145144
return client.query_points(
@@ -343,10 +342,8 @@ def test_query_with_nan():
343342

344343
fixture_points = generate_sparse_fixtures()
345344
sparse_vector = random_sparse_vectors({"sparse-text": sparse_text_vector_size})
346-
named_sparse_vector = models.NamedSparseVector(
347-
name="sparse-text", vector=sparse_vector["sparse-text"]
348-
)
349-
named_sparse_vector.vector.values[0] = np.nan
345+
346+
sparse_vector["sparse-text"].values[0] = np.nan
350347

351348
local_client.create_collection(
352349
COLLECTION_NAME, vectors_config={}, sparse_vectors_config=sparse_vectors_config
@@ -370,6 +367,10 @@ def test_query_with_nan():
370367
)
371368

372369
with pytest.raises(AssertionError):
373-
local_client.search(COLLECTION_NAME, named_sparse_vector)
370+
local_client.query_points(
371+
COLLECTION_NAME, sparse_vector["sparse-text"], using="sparse-text"
372+
)
374373
with pytest.raises(UnexpectedResponse):
375-
remote_client.search(COLLECTION_NAME, named_sparse_vector)
374+
remote_client.query_points(
375+
COLLECTION_NAME, sparse_vector["sparse-text"], using="sparse-text"
376+
)

0 commit comments

Comments
 (0)