mirror of
https://github.com/qdrant/qdrant-client.git
synced 2026-07-28 21:51:07 -05:00
* new: remove vectors_count, update http and grpc models * fix: update inspection cache * new: add conversions and update interface * fix: fix some conversions * fix: fix typo * fix: fix isinstance * fix: regen async * fix: fix update_filter usage, fix isinstance * tests: collection metadata test * fix: address backward compatibility in test * new: update models, add max payload index count and copy vectors * fix; update _inspection_cache * new: add read consistency to count points * Allow uuids in interface (#1085) * new: direct uuid support * tests: add uuid tests * fix: update inspection cache * new: add collection metadata and tests to local mode (#1089) * new: add collection metadata and tests to local mode * fix: regen async client * new: implement parametrized rrf in local mode (#1087) * new: implement parametrized rrf in local mode * refactoring: use a variable for a magic value * fix: adjust conversion according to AI * Update filter (#1090) * new: add missing update_filter, implement it in local mode * fix: fix type hint, fix update operation, fix rest uploader, add tests * fix: fix update filter is None case * fix: mypy was not a good boy * Text any filter (#1091) * new: add match text any local mode * tests: add match text any tests * new: update models, remove init_from and locks (#1100) * new: update models, remove init_from and locks * deprecate: remove init from tests * deprecate: remove lock tests * new: convert ascii_folding * fix: fix type stub * new: convert acorn * new: convert shard key with fallback * new: update grpcio and grpcio tools in generator (#1106) * new: update grpcio and grpcio tools in generator * fix: bind grpcio and tools versions to 1.62.0 in generator * Remove deprecated methods (#1103) * deprecate: remove old api methods * deprecate: remove type stub for removed methods * deprecate: remove old api methods from test_qdrant_client * deprecate: replace search with query points in test_in_memory * deprecate: replace search methods in fastembed mixin with query points * deprecate: replace old api methods in test async qdrant client * deprecate: replace search with query points in test delete points * deprecate: replace discover and context with query points in test_discovery * deprecate: replace recommend_groups with query_points_groups in test_group_recommend * deprecate: replace search_groups in test_group_search * deprecate: replace recommend with query points in test_recommendation * deprecate: replace search with query points in test search * deprecate: replace context and discover with query points in test sparse discovery * deprecate: replace search with query points in test sparse idf search * deprecate: replace recommend with query points in test sparse recommend * deprecate: replace search with query points in test sparse search * deprecate: replace missing search request with query request in qdrant_fastembed * deprecate: replace search with query points in test multivector search queries * deprecate: replace upload records with upload points in test_updates * deprecate: remove redundant structs (#1104) * deprecate: remove redundant structs * fix: do not use removed conversions in local mode * fix: remove redundant conversions, simplify types.QueryRequest * deprecate: replace old style grpc vector conversion to a new one (#1105) * deprecate: replace old style grpc vector conversion to a new one * fix: ignore union attr in conversion * review fixes --------- Co-authored-by: generall <andrey@vasnetsov.com> --------- Co-authored-by: generall <andrey@vasnetsov.com> --------- Co-authored-by: generall <andrey@vasnetsov.com> * new: deprecate add, query, query_batch in fastembed mixin (#1102) * new: deprecate add, query, query_batch in fastembed mixin * 1.16 -> 1.17 --------- Co-authored-by: generall <andrey@vasnetsov.com> --------- Co-authored-by: generall <andrey@vasnetsov.com> * new: yet another update * new: add initial_state to create shard key (#1109) * chore: remove obsolete imports * fix: add metadata parameter to recreate collection in local * fix: fix metadata handling in local more --------- Co-authored-by: generall <andrey@vasnetsov.com>
121 lines
3.8 KiB
Python
121 lines
3.8 KiB
Python
import pytest
|
|
|
|
from qdrant_client import QdrantClient, models
|
|
|
|
|
|
@pytest.fixture
|
|
def qdrant() -> QdrantClient:
|
|
return QdrantClient(":memory:")
|
|
|
|
|
|
def test_dense_in_memory_key_filter_returns_results(qdrant: QdrantClient):
|
|
qdrant.create_collection(
|
|
collection_name="test_collection",
|
|
vectors_config=models.VectorParams(size=4, distance=models.Distance.DOT),
|
|
)
|
|
|
|
operation_info = qdrant.upsert(
|
|
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=2,
|
|
vector=[0.19, 0.81, 0.75, 0.11],
|
|
payload={"city": ["Berlin", "London"]},
|
|
),
|
|
models.PointStruct(
|
|
id=3,
|
|
vector=[0.36, 0.55, 0.47, 0.94],
|
|
payload={"city": ["Berlin", "Moscow"]},
|
|
),
|
|
models.PointStruct(
|
|
id=4,
|
|
vector=[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]),
|
|
],
|
|
)
|
|
|
|
assert operation_info.operation_id == 0
|
|
assert operation_info.status == models.UpdateStatus.COMPLETED
|
|
|
|
search_result = qdrant.query_points(
|
|
collection_name="test_collection",
|
|
query=[0.2, 0.1, 0.9, 0.7],
|
|
query_filter=models.Filter(
|
|
must=[models.FieldCondition(key="city", match=models.MatchValue(value="London"))]
|
|
),
|
|
limit=3,
|
|
).points
|
|
|
|
assert [r.id for r in search_result] == [4, 2]
|
|
|
|
|
|
def test_sparse_in_memory_key_filter_returns_results(qdrant: QdrantClient):
|
|
qdrant.create_collection(
|
|
collection_name="test_collection",
|
|
vectors_config={},
|
|
sparse_vectors_config={"text": models.SparseVectorParams()},
|
|
)
|
|
|
|
operation_info = qdrant.upsert(
|
|
collection_name="test_collection",
|
|
wait=True,
|
|
points=[
|
|
models.PointStruct(
|
|
id=1,
|
|
vector={
|
|
"text": models.SparseVector(
|
|
indices=[0, 1, 2, 3], values=[0.05, 0.61, 0.76, 0.74]
|
|
)
|
|
},
|
|
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]
|
|
)
|
|
},
|
|
payload={"city": ["Berlin", "London"]},
|
|
),
|
|
models.PointStruct(
|
|
id=3,
|
|
vector={
|
|
"text": models.SparseVector(
|
|
indices=[0, 1, 2, 3], values=[0.36, 0.55, 0.47, 0.94]
|
|
)
|
|
},
|
|
payload={"city": ["Berlin", "Moscow"]},
|
|
),
|
|
models.PointStruct(
|
|
id=4,
|
|
vector={
|
|
"text": models.SparseVector(
|
|
indices=[0, 1, 2, 3], values=[0.18, 0.01, 0.85, 0.80]
|
|
)
|
|
},
|
|
payload={"city": ["London", "Moscow"]},
|
|
),
|
|
],
|
|
)
|
|
|
|
assert operation_info.operation_id == 0
|
|
assert operation_info.status == models.UpdateStatus.COMPLETED
|
|
|
|
search_result = qdrant.query_points(
|
|
collection_name="test_collection",
|
|
using="text",
|
|
query=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"))]
|
|
),
|
|
limit=3,
|
|
).points
|
|
|
|
assert [r.id for r in search_result] == [4, 2]
|