Skip to content

fix Update qdrant_impl.py #1253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions lightrag/kg/qdrant_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,50 @@ async def search_by_prefix(self, prefix: str) -> list[dict[str, Any]]:
except Exception as e:
logger.error(f"Error searching for prefix '{prefix}': {e}")
return []

async def get_by_id(self, id: str) -> dict[str, Any] | None:
"""Get vector data by its ID

Args:
id: The unique identifier of the vector

Returns:
The vector data if found, or None if not found
"""
try:
qdrant_id = compute_mdhash_id_for_qdrant(id)
result = self._client.retrieve(
collection_name=self.namespace,
ids=[qdrant_id],
with_payload=True
)
if result and len(result) > 0:
return {**result[0].payload}
return None
except Exception as e:
logger.error(f"Error getting vector by ID {id}: {e}")
return None

async def get_by_ids(self, ids: list[str]) -> list[dict[str, Any]]:
"""Get multiple vector data by their IDs

Args:
ids: List of unique identifiers

Returns:
List of vector data objects that were found
"""
if not ids:
return []

try:
qdrant_ids = [compute_mdhash_id_for_qdrant(id) for id in ids]
results = self._client.retrieve(
collection_name=self.namespace,
ids=qdrant_ids,
with_payload=True
)
return [{**point.payload} for point in results if point]
except Exception as e:
logger.error(f"Error getting vectors by IDs: {e}")
return []