Initial Checks
Description
This issue occurs when we use the existing qdrant vector db which is not created by the Docarray library.
def _convert_to_doc(
self, point: Union[rest.ScoredPoint, rest.Record]
) -> Dict[str, Any]:
document = cast(Dict[str, Any], point.payload)
--> generated_vectors = document.pop('__generated_vectors'). <--
vectors = point.vector if point.vector else dict()
if not isinstance(vectors, dict):
vectors = {'__default__': vectors}
for vector_name, vector in vectors.items():
if vector_name in generated_vectors:
# That means the vector was generated during the upload, and should not
# be returned along the other vectors.
pass
document[vector_name] = vector
return document
Example Code
results = doc_index.find(
query=model.encode(["chinese"])[0],
search_field="cuisine_vector",
limit=3,
)
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:2 │
│ │
│ 1 # Performing a vector search only │
│ ❱ 2 results = doc_index.find( │
│ 3 │ query=model.encode(["chinese"])[0], │
│ 4 │ search_field="cuisine_vector", │
│ 5 │ limit=3, │
│ │
│ /Users/ikram.ali/miniconda3/envs/deetshub/lib/python3.10/site-packages/docarray/index/abstract.p │
│ y:466 in find │
│ │
│ 463 │ │ else: │
│ 464 │ │ │ query_vec = query │
│ 465 │ │ query_vec_np = self._to_numpy(query_vec) │
│ ❱ 466 │ │ docs, scores = self._find( │
│ 467 │ │ │ query_vec_np, search_field=search_field, limit=limit, **kwargs │
│ 468 │ │ ) │
│ 469 │
│ │
│ /Users/ikram.ali/miniconda3/envs/deetshub/lib/python3.10/site-packages/docarray/index/backends/q │
│ drant.py:439 in _find │
│ │
│ 436 │ │ self, query: np.ndarray, limit: int, search_field: str = '' │
│ 437 │ ) -> _FindResult: │
│ 438 │ │ query_batched = np.expand_dims(query, axis=0) │
│ ❱ 439 │ │ docs, scores = self._find_batched( │
│ 440 │ │ │ queries=query_batched, limit=limit, search_field=search_field │
│ 441 │ │ ) │
│ 442 │ │ return _FindResult(documents=docs[0], scores=scores[0]) # type: ignore[arg-type │
│ │
│ /Users/ikram.ali/miniconda3/envs/deetshub/lib/python3.10/site-packages/docarray/index/backends/q │
│ drant.py:474 in _find_batched │
│ │
│ 471 │ │ │ ], │
│ 472 │ │ ) │
│ 473 │ │ return _FindResultBatched( │
│ ❱ 474 │ │ │ documents=[ │
│ 475 │ │ │ │ [self._convert_to_doc(point) for point in response] │
│ 476 │ │ │ │ for response in responses │
│ 477 │ │ │ ], │
│ │
│ /Users/ikram.ali/miniconda3/envs/deetshub/lib/python3.10/site-packages/docarray/index/backends/q │
│ drant.py:475 in <listcomp> │
│ │
│ 472 │ │ ) │
│ 473 │ │ return _FindResultBatched( │
│ 474 │ │ │ documents=[ │
│ ❱ 475 │ │ │ │ [self._convert_to_doc(point) for point in response] │
│ 476 │ │ │ │ for response in responses │
│ 477 │ │ │ ], │
│ 478 │ │ │ scores=[ │
│ │
│ /Users/ikram.ali/miniconda3/envs/deetshub/lib/python3.10/site-packages/docarray/index/backends/q │
│ drant.py:475 in <listcomp> │
│ │
│ 472 │ │ ) │
│ 473 │ │ return _FindResultBatched( │
│ 474 │ │ │ documents=[ │
│ ❱ 475 │ │ │ │ [self._convert_to_doc(point) for point in response] │
│ 476 │ │ │ │ for response in responses │
│ 477 │ │ │ ], │
│ 478 │ │ │ scores=[ │
│ │
│ /Users/ikram.ali/miniconda3/envs/deetshub/lib/python3.10/site-packages/docarray/index/backends/q │
│ drant.py:615 in _convert_to_doc │
│ │
│ 612 │ │ self, point: Union[rest.ScoredPoint, rest.Record] │
│ 613 │ ) -> Dict[str, Any]: │
│ 614 │ │ document = cast(Dict[str, Any], point.payload) │
│ ❱ 615 │ │ generated_vectors = document.pop('__generated_vectors') │
│ 616 │ │ vectors = point.vector if point.vector else dict() │
│ 617 │ │ if not isinstance(vectors, dict): │
│ 618 │ │ │ vectors = {'__default__': vectors} │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
KeyError: '__generated_vectors'
Python, Pydantic & OS Version
Affected Components
Initial Checks
Description
This issue occurs when we use the existing qdrant vector db which is not created by the Docarray library.
Example Code
Python, Pydantic & OS Version
Affected Components