Single-store text_key / index_doc_id
FullExercise: Deterministic Qdrant Index with Single-Store Text
Goal
Implement the function build_deduped_qdrant_index(nodes, embed_model, namespace="") that creates a VectorStoreIndex backed by Qdrant, following the pattern from the provided repository source. This ensures that re-running the same corpus upserts existing Qdrant points instead of appending duplicates.
Requirements
- Deterministic Node IDs: Assign each node a stable
uuid5ID derived from its text content and thenamespace. Do not rely on random or default IDs. - Corpus-Fingerprinted Collection Name: Use
_collection_name(nodes, namespace=namespace)as defined in the source (fingerprint = SHA‑256 of sorted node IDs, truncated to 12 hex chars, prefixed with"kg-"and namespace). - QdrantVectorStore Configuration: Create the store with
index_doc_id=Trueandtext_key="text". - StorageContext: Use
StorageContext.from_defaults(vector_store=...). - Return the index: Return the resulting
VectorStoreIndex. - Explain the empty docstore: In a comment (or docstring), explain why
index.docstore.docsis intentionally empty on the Qdrant path, referencing the source's design.
Assumptions
nodesis a list ofTextNodeobjects withtextandembeddingattributes already set.embed_modelis an embedding model (e.g., frommake_embed()).- You have access to
QdrantVectorStore,StorageContext,VectorStoreIndex, and a_get_qdrant_client()(assume it returns a validQdrantClient). - The
_collection_namefunction is already available (you can reimplement it exactly as in the source). - Do not modify the internals of the source’s
build_index_from_nodes; write your own function that replicates the pattern.
Starter Code
Deliverable
Provide the complete Python implementation of build_deduped_qdrant_index, including all helper logic (deterministic IDs, collection name, Qdrant wiring) and the required explanation.
Your code
Sources
- roadmap-kg/kg/memory_common.py:920-928
- roadmap-kg/kg/memory_common.py:931-972
- roadmap-kg/kg/ground_content.py:519-546