Skip to content

Commit 977fcf4

Browse files
committed
new: add read consistency to count points
1 parent 6e0bb9a commit 977fcf4

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
@@ -1525,13 +1525,16 @@ async def count(
15251525
exact: bool = True,
15261526
shard_key_selector: Optional[types.ShardKeySelector] = None,
15271527
timeout: Optional[int] = None,
1528+
consistency: Optional[types.ReadConsistency] = None,
15281529
**kwargs: Any,
15291530
) -> types.CountResult:
15301531
if self._prefer_grpc:
15311532
if isinstance(count_filter, models.Filter):
15321533
count_filter = RestToGrpc.convert_filter(model=count_filter)
15331534
if isinstance(shard_key_selector, get_args_subscribed(models.ShardKeySelector)):
15341535
shard_key_selector = RestToGrpc.convert_shard_key_selector(shard_key_selector)
1536+
if isinstance(consistency, get_args_subscribed(models.ReadConsistency)):
1537+
consistency = RestToGrpc.convert_read_consistency(consistency)
15351538
response = (
15361539
await self.grpc_points.Count(
15371540
grpc.CountPoints(
@@ -1540,6 +1543,7 @@ async def count(
15401543
exact=exact,
15411544
shard_key_selector=shard_key_selector,
15421545
timeout=timeout,
1546+
read_consistency=consistency,
15431547
),
15441548
timeout=timeout if timeout is not None else self._timeout,
15451549
)
@@ -1553,6 +1557,7 @@ async def count(
15531557
count_request=models.CountRequest(
15541558
filter=count_filter, exact=exact, shard_key=shard_key_selector
15551559
),
1560+
consistency=consistency,
15561561
timeout=timeout,
15571562
)
15581563
).result

qdrant_client/qdrant_remote.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,7 @@ def count(
17421742
exact: bool = True,
17431743
shard_key_selector: Optional[types.ShardKeySelector] = None,
17441744
timeout: Optional[int] = None,
1745+
consistency: Optional[types.ReadConsistency] = None,
17451746
**kwargs: Any,
17461747
) -> types.CountResult:
17471748
if self._prefer_grpc:
@@ -1751,13 +1752,17 @@ def count(
17511752
if isinstance(shard_key_selector, get_args_subscribed(models.ShardKeySelector)):
17521753
shard_key_selector = RestToGrpc.convert_shard_key_selector(shard_key_selector)
17531754

1755+
if isinstance(consistency, get_args_subscribed(models.ReadConsistency)):
1756+
consistency = RestToGrpc.convert_read_consistency(consistency)
1757+
17541758
response = self.grpc_points.Count(
17551759
grpc.CountPoints(
17561760
collection_name=collection_name,
17571761
filter=count_filter,
17581762
exact=exact,
17591763
shard_key_selector=shard_key_selector,
17601764
timeout=timeout,
1765+
read_consistency=consistency,
17611766
),
17621767
timeout=timeout if timeout is not None else self._timeout,
17631768
).result
@@ -1773,6 +1778,7 @@ def count(
17731778
exact=exact,
17741779
shard_key=shard_key_selector,
17751780
),
1781+
consistency=consistency,
17761782
timeout=timeout,
17771783
).result
17781784
assert count_result is not None, "Count points returned None result"

0 commit comments

Comments
 (0)