Files
qdrant-client/tests/congruence_tests/test_retrieve.py
Andrey Vasnetsov 392e3b6d1f Local qdrant (#137)
* base class for qdrant

* WIP: implement local qdrant client

* fix mypy

* fix mypy

* search tests

* search tests

* fix mypy

* scroll test

* filters: fixtures, tests, and fixes

* fix types

* fix types

* fix types

* fix: fix local CollectionInfo, add __test__ to avoid pytest complaints, fix typo

* fix: fix typo in import

* tests: add local upload tests (#139)

* new: make local collection info more similar to remote one

* new: add local upsert tests

* tests: moved compare collections

* scroll tests

* recommendations test

* tests: fix vector comparison in utils, add retrieve tests

* fix: fix types

* persistence test

* fix: fix types

* fix: fix db path creation

* tests: add delete points tests, refactoring (#140)

* skip local tests on old version

* test aliases

* test count

* tests: add delete payload tests, move set and overwrite payload tests

* tests: fix pytest warning

* cover some more stuff with tests

---------

Co-authored-by: George Panchuk <george.panchuk@qdrant.tech>
2023-03-28 14:57:05 +02:00

69 lines
2.0 KiB
Python

import random
from qdrant_client.http.models import PayloadSelectorExclude, PayloadSelectorInclude
from tests.congruence_tests.test_common import (
COLLECTION_NAME,
compare_client_results,
generate_fixtures,
)
def test_retrieve(local_client, remote_client) -> None:
num_vectors = 1000
fixture_records = generate_fixtures(num_vectors)
keys = list(fixture_records[0].payload.keys())
local_client.upload_records(COLLECTION_NAME, fixture_records)
remote_client.upload_records(COLLECTION_NAME, fixture_records)
id_ = random.randint(0, num_vectors)
compare_client_results(
local_client, remote_client, lambda c: c.retrieve(COLLECTION_NAME, [id_])
)
compare_client_results(
local_client,
remote_client,
lambda c: c.retrieve(COLLECTION_NAME, [id_], with_payload=False),
)
# with_vectors is not tested with `True` because `text` vectors are used with Cosine distance,
# and we do not normalize them in local version
compare_client_results(
local_client,
remote_client,
lambda c: c.retrieve(COLLECTION_NAME, [id_], with_vectors=["image", "code"]),
)
compare_client_results(
local_client,
remote_client,
lambda c: c.retrieve(
COLLECTION_NAME, [id_], with_vectors=["image", "code"], with_payload=False
),
)
sample_keys = random.sample(keys, 3)
compare_client_results(
local_client,
remote_client,
lambda c: c.retrieve(COLLECTION_NAME, [id_], with_payload=sample_keys),
)
compare_client_results(
local_client,
remote_client,
lambda c: c.retrieve(
COLLECTION_NAME,
[id_],
with_payload=PayloadSelectorInclude(include=sample_keys),
),
)
compare_client_results(
local_client,
remote_client,
lambda c: c.retrieve(
COLLECTION_NAME,
[id_],
with_payload=PayloadSelectorExclude(exclude=sample_keys),
),
)