mirror of
https://github.com/qdrant/qdrant.git
synced 2026-08-04 17:10:59 -05:00
* Refactor `PyUpdateOperation` constructors * Add default parameters to `PyVectorDataConfig::new` * Add `Repr` trait and `WriteExt` helper * Implement `__repr__` for config types * fixup! Implement `__repr__` for config types Use `Copy` instead of `Clone` * fixup! Implement `__repr__` for config types Add basic test * Implement `__repr__` for `PyPointId` * Implement `__repr__` for `PyVector` * Implement `__repr__` for `PyVectorInternal` * Implement `__repr__` for `PyPayload` * Implement `__repr__` for `PyValue` * Implement `__repr__` for `PyPoint` * Implement `__repr__` for `PyPointVectors` * Implement `__repr__` for `PyRecord` * Move `PyScoredPoint` into a separate file * Implement `__repr__` for `PyScoredPoint` * Cleanup examples * fixup! Implement `__repr__` for `PyScoredPoint` * Move `PyOrderValue` into separate file * Add `PyScoredPoint::order_value` * Implement `pyclass_repr` proc-macro attribute * Implement `__repr__` for config types using `pyclass_repr` attribute * Implement `__repr__` for `PySparseVector` using `pyclass_repr` attribute * Implement `__repr__` for `PyPoint` using `pyclass_repr` attribute * Implement `__repr__` for `PyPointVectors` using `pyclass_repr` attribute * Implement `__repr__` for `PyRecord` using `pyclass_repr` attribute * Implement `__repr__` for `PyScoredPoint` using `pyclass_repr` attribute * Minor fixes and cleanups * fixup! Minor fixes and cleanups * rollback copy for quantization config * rollback copy for quantization config --------- Co-authored-by: generall <andrey@vasnetsov.com>
140 lines
2.6 KiB
Python
Executable File
140 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from qdrant_edge import *
|
|
from common import *
|
|
|
|
|
|
print("---- Point conversions ----")
|
|
|
|
points = [
|
|
Point(10, [[1,2,3], [3, 4, 5]], {}),
|
|
Point(11, { "sparse": SparseVector(indices=[0, 2], values=[1.0, 3.0]) }, {}),
|
|
]
|
|
|
|
# Test points conversion into internal representation and back
|
|
for point in points:
|
|
print(point)
|
|
|
|
|
|
print("---- Load shard ----")
|
|
|
|
shard = load_new_shard()
|
|
|
|
|
|
print("---- Upsert ----")
|
|
|
|
shard.update(UpdateOperation.upsert_points([
|
|
Point(
|
|
1,
|
|
[6.0, 9.0, 4.0, 2.0],
|
|
{
|
|
"null": None,
|
|
"str": "string",
|
|
"uint": 42,
|
|
"int": -69,
|
|
"float": 4.20,
|
|
"bool": True,
|
|
"obj": {
|
|
"null": None,
|
|
"str": "string",
|
|
"uint": 42,
|
|
"int": -69,
|
|
"float": 4.20,
|
|
"bool": True,
|
|
"obj": {},
|
|
"arr": [],
|
|
},
|
|
"arr": [None, "string", 42, -69, 4.20, True, {}, []],
|
|
},
|
|
),
|
|
Point(
|
|
"e9408f2b-b917-4af1-ab75-d97ac6b2c047",
|
|
[6.0, 9.0, 3.0, -2.0],
|
|
{
|
|
"hello": "world",
|
|
"price": 199.99,
|
|
},
|
|
),
|
|
Point(
|
|
uuid.uuid4(),
|
|
[1.0, 6.0, 4.0, 2.0],
|
|
{
|
|
"hello": "world",
|
|
"price": 999.99,
|
|
},
|
|
),
|
|
]))
|
|
|
|
|
|
print("---- Query ----")
|
|
|
|
result = shard.query(QueryRequest(
|
|
prefetches = [],
|
|
query = Query.Nearest([6.0, 9.0, 4.0, 2.0]),
|
|
filter = None,
|
|
score_threshold = None,
|
|
limit = 10,
|
|
offset = 0,
|
|
params = None,
|
|
with_vector = True,
|
|
with_payload = True,
|
|
))
|
|
|
|
for point in result:
|
|
print(point)
|
|
|
|
|
|
print("---- Search ----")
|
|
|
|
points = shard.search(SearchRequest(
|
|
query=Query.Nearest([1.0, 1.0, 1.0, 1.0]),
|
|
filter=None,
|
|
params=None,
|
|
limit=10,
|
|
offset=0,
|
|
with_vector=True,
|
|
with_payload=True,
|
|
score_threshold=None,
|
|
))
|
|
|
|
for point in points:
|
|
print(point)
|
|
|
|
|
|
print("---- Search + Filter ----")
|
|
|
|
search_filter = Filter(
|
|
must=[
|
|
FieldCondition(
|
|
key="hello",
|
|
match=MatchTextAny(text_any="world"),
|
|
),
|
|
FieldCondition(
|
|
key="price",
|
|
range=RangeFloat(gte=500.0),
|
|
)
|
|
]
|
|
)
|
|
|
|
points = shard.search(SearchRequest(
|
|
query=Query.Nearest([1.0, 1.0, 1.0, 1.0]),
|
|
filter=search_filter,
|
|
params=None,
|
|
limit=10,
|
|
offset=0,
|
|
with_vector=True,
|
|
with_payload=True,
|
|
score_threshold=None,
|
|
))
|
|
|
|
for point in points:
|
|
print(point)
|
|
|
|
|
|
print("---- Retrieve ----")
|
|
|
|
points = shard.retrieve(point_ids=[1], with_vector=True, with_payload=True)
|
|
|
|
for point in points:
|
|
print(point)
|