fix: harden qdrant payload and paging
This commit is contained in:
@@ -318,15 +318,32 @@ class QdrantVectorStore:
|
||||
return result
|
||||
|
||||
def _scroll(self, must: list[dict]) -> list[dict]:
|
||||
response = self._call(
|
||||
"POST",
|
||||
f"/collections/{self._collection}/points/scroll",
|
||||
{"with_payload": True, "limit": 10000, "filter": {"must": must}},
|
||||
)
|
||||
points = response.get("result", {}).get("points")
|
||||
if not isinstance(points, list):
|
||||
raise VectorStoreError("Qdrant returned malformed scroll response")
|
||||
return points
|
||||
points: list[dict] = []
|
||||
offset = None
|
||||
seen_offsets = set()
|
||||
while True:
|
||||
response = self._call(
|
||||
"POST",
|
||||
f"/collections/{self._collection}/points/scroll",
|
||||
{
|
||||
"with_payload": True,
|
||||
"limit": 10000,
|
||||
"filter": {"must": must},
|
||||
"offset": offset,
|
||||
},
|
||||
)
|
||||
result = response.get("result", {})
|
||||
page = result.get("points")
|
||||
if not isinstance(page, list):
|
||||
raise VectorStoreError("Qdrant returned malformed scroll response")
|
||||
points.extend(page)
|
||||
next_page_offset = result.get("next_page_offset")
|
||||
if next_page_offset is None:
|
||||
return points
|
||||
if next_page_offset in seen_offsets:
|
||||
raise VectorStoreError("Qdrant returned malformed scroll response")
|
||||
seen_offsets.add(next_page_offset)
|
||||
offset = next_page_offset
|
||||
|
||||
def _hit_from_point(self, point: dict) -> VectorHit:
|
||||
payload = point.get("payload")
|
||||
|
||||
Reference in New Issue
Block a user