Skip to content

Adding support of multi-vector collection for Qdrant driver #312

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

Merged
merged 6 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Next

### Added

- Added support for multi-vector collection in Qdrant driver.

### Changed

- Improved log output readability in Retrievers and GraphRAG and added embedded vector to retriever result metadata for debugging.
Expand Down
1 change: 1 addition & 0 deletions docs/source/user_guide_rag.rst
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ Qdrant Retrievers
driver=driver,
client=client,
collection_name="my-collection",
using="my-vector",
id_property_external="neo4j_id", # The payload field that contains identifier to a corresponding Neo4j node id property
id_property_neo4j="id",
embedder=embedder,
Expand Down
6 changes: 6 additions & 0 deletions src/neo4j_graphrag/retrievers/external/qdrant/qdrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class QdrantNeo4jRetriever(ExternalRetriever):
driver=neo4j_driver,
client=client,
collection_name="my_collection",
using="my_vector",
id_property_external="neo4j_id"
)
embedding = ...
Expand All @@ -71,6 +72,7 @@ class QdrantNeo4jRetriever(ExternalRetriever):
driver (neo4j.Driver): The Neo4j Python driver.
client (QdrantClient): The Qdrant client object.
collection_name (str): The name of the Qdrant collection to use.
using (str): The name of the Qdrant vector contained in your collection in case of multi-vector collection
id_property_neo4j (str): The name of the Neo4j node property that's used as the identifier for relating matches from Qdrant to Neo4j nodes.
id_property_external (str): The name of the Qdrant payload property with identifier that refers to a corresponding Neo4j node id property.
embedder (Optional[Embedder]): Embedder object to embed query text.
Expand All @@ -89,6 +91,7 @@ def __init__(
collection_name: str,
id_property_neo4j: str,
id_property_external: str = "id",
using: Optional[str] = None,
embedder: Optional[Embedder] = None,
return_properties: Optional[list[str]] = None,
retrieval_query: Optional[str] = None,
Expand All @@ -105,6 +108,7 @@ def __init__(
driver_model=driver_model,
client_model=client_model,
collection_name=collection_name,
using=using,
id_property_neo4j=id_property_neo4j,
id_property_external=id_property_external,
embedder_model=embedder_model,
Expand All @@ -125,6 +129,7 @@ def __init__(
self.driver = validated_data.driver_model.driver
self.client = validated_data.client_model.client
self.collection_name = validated_data.collection_name
self.using = validated_data.using
self.embedder = (
validated_data.embedder_model.embedder
if validated_data.embedder_model
Expand Down Expand Up @@ -202,6 +207,7 @@ def get_search_results(
points = self.client.query_points(
collection_name=self.collection_name,
query=query_vector,
using=self.using,
limit=top_k,
with_payload=[self.id_property_external],
**kwargs,
Expand Down
1 change: 1 addition & 0 deletions src/neo4j_graphrag/retrievers/external/qdrant/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class QdrantNeo4jRetrieverModel(BaseModel):
collection_name: str
id_property_external: str
id_property_neo4j: str
using: Optional[str] = None
embedder_model: Optional[EmbedderModel] = None
return_properties: Optional[list[str]] = None
retrieval_query: Optional[str] = None
Expand Down