Skip to content

Commit

Permalink
fix: fix sparse vectors test, do not insert dense vector if config is…
Browse files Browse the repository at this point in the history
… empty
  • Loading branch information
joein committed Jan 18, 2024
1 parent 1fa9c7b commit 1e29798
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions tests/test_in_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ def test_dense_in_memory_key_filter_returns_results(qdrant: QdrantClient):
collection_name="test_collection",
wait=True,
points=[
models.PointStruct(
id=1,
vector=[0.05, 0.61, 0.76, 0.74],
payload={"city": "Berlin"}
),
models.PointStruct(id=1, vector=[0.05, 0.61, 0.76, 0.74], payload={"city": "Berlin"}),
models.PointStruct(
id=2,
vector=[0.19, 0.81, 0.75, 0.11],
Expand Down Expand Up @@ -73,18 +69,16 @@ def test_sparse_in_memory_key_filter_returns_results(qdrant: QdrantClient):
id=1,
vector={
"text": models.SparseVector(
indices=[0, 1, 2, 3],
values=[0.05, 0.61, 0.76, 0.74]
indices=[0, 1, 2, 3], values=[0.05, 0.61, 0.76, 0.74]
)
},
payload={"city": "Berlin"}
payload={"city": "Berlin"},
),
models.PointStruct(
id=2,
vector={
"text": models.SparseVector(
indices=[0, 1, 2, 3],
values=[0.19, 0.81, 0.75, 0.11]
indices=[0, 1, 2, 3], values=[0.19, 0.81, 0.75, 0.11]
)
},
payload={"city": ["Berlin", "London"]},
Expand All @@ -93,8 +87,7 @@ def test_sparse_in_memory_key_filter_returns_results(qdrant: QdrantClient):
id=3,
vector={
"text": models.SparseVector(
indices=[0, 1, 2, 3],
values=[0.36, 0.55, 0.47, 0.94]
indices=[0, 1, 2, 3], values=[0.36, 0.55, 0.47, 0.94]
)
},
payload={"city": ["Berlin", "Moscow"]},
Expand All @@ -103,14 +96,11 @@ def test_sparse_in_memory_key_filter_returns_results(qdrant: QdrantClient):
id=4,
vector={
"text": models.SparseVector(
indices=[0, 1, 2, 3],
values=[0.18, 0.01, 0.85, 0.80]
indices=[0, 1, 2, 3], values=[0.18, 0.01, 0.85, 0.80]
)
},
payload={"city": ["London", "Moscow"]},
),
models.PointStruct(id=5, vector=[0.24, 0.18, 0.22, 0.44], payload={"count": [0]}),
models.PointStruct(id=6, vector=[0.35, 0.08, 0.11, 0.44]),
],
)

Expand All @@ -121,10 +111,7 @@ def test_sparse_in_memory_key_filter_returns_results(qdrant: QdrantClient):
collection_name="test_collection",
query_vector=models.NamedSparseVector(
name="text",
vector=models.SparseVector(
indices=[0, 1, 2, 3],
values=[0.2, 0.1, 0.9, 0.7]
)
vector=models.SparseVector(indices=[0, 1, 2, 3], values=[0.2, 0.1, 0.9, 0.7]),
),
query_filter=models.Filter(
must=[models.FieldCondition(key="city", match=models.MatchValue(value="London"))]
Expand Down

0 comments on commit 1e29798

Please sign in to comment.