Skip to content

Commit 4a4d40e

Browse files
committed
new: add read consistency to count points
1 parent f113fef commit 4a4d40e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

qdrant_client/async_qdrant_remote.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,13 +1577,16 @@ async def count(
15771577
exact: bool = True,
15781578
shard_key_selector: Optional[types.ShardKeySelector] = None,
15791579
timeout: Optional[int] = None,
1580+
consistency: Optional[types.ReadConsistency] = None,
15801581
**kwargs: Any,
15811582
) -> types.CountResult:
15821583
if self._prefer_grpc:
15831584
if isinstance(count_filter, models.Filter):
15841585
count_filter = RestToGrpc.convert_filter(model=count_filter)
15851586
if isinstance(shard_key_selector, get_args_subscribed(models.ShardKeySelector)):
15861587
shard_key_selector = RestToGrpc.convert_shard_key_selector(shard_key_selector)
1588+
if isinstance(consistency, get_args_subscribed(models.ReadConsistency)):
1589+
consistency = RestToGrpc.convert_read_consistency(consistency)
15871590
response = (
15881591
await self.grpc_points.Count(
15891592
grpc.CountPoints(
@@ -1592,6 +1595,7 @@ async def count(
15921595
exact=exact,
15931596
shard_key_selector=shard_key_selector,
15941597
timeout=timeout,
1598+
read_consistency=consistency,
15951599
),
15961600
timeout=timeout if timeout is not None else self._timeout,
15971601
)
@@ -1605,6 +1609,7 @@ async def count(
16051609
count_request=models.CountRequest(
16061610
filter=count_filter, exact=exact, shard_key=shard_key_selector
16071611
),
1612+
consistency=consistency,
16081613
timeout=timeout,
16091614
)
16101615
).result

qdrant_client/qdrant_remote.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,7 @@ def count(
18031803
exact: bool = True,
18041804
shard_key_selector: Optional[types.ShardKeySelector] = None,
18051805
timeout: Optional[int] = None,
1806+
consistency: Optional[types.ReadConsistency] = None,
18061807
**kwargs: Any,
18071808
) -> types.CountResult:
18081809
if self._prefer_grpc:
@@ -1812,13 +1813,17 @@ def count(
18121813
if isinstance(shard_key_selector, get_args_subscribed(models.ShardKeySelector)):
18131814
shard_key_selector = RestToGrpc.convert_shard_key_selector(shard_key_selector)
18141815

1816+
if isinstance(consistency, get_args_subscribed(models.ReadConsistency)):
1817+
consistency = RestToGrpc.convert_read_consistency(consistency)
1818+
18151819
response = self.grpc_points.Count(
18161820
grpc.CountPoints(
18171821
collection_name=collection_name,
18181822
filter=count_filter,
18191823
exact=exact,
18201824
shard_key_selector=shard_key_selector,
18211825
timeout=timeout,
1826+
read_consistency=consistency,
18221827
),
18231828
timeout=timeout if timeout is not None else self._timeout,
18241829
).result
@@ -1834,6 +1839,7 @@ def count(
18341839
exact=exact,
18351840
shard_key=shard_key_selector,
18361841
),
1842+
consistency=consistency,
18371843
timeout=timeout,
18381844
).result
18391845
assert count_result is not None, "Count points returned None result"

0 commit comments

Comments
 (0)