ok, let me explain the problem -
I am creating two different
index
over the same data, one is the
VectorStoreIndex
and another one is
SummaryIndex
and I am using Qdrant vector store to store them. Here is the code -
ingest.py
client = QdrantClient(path="./vector_store/db")
qdrant_vector_store = QdrantVectorStore(client= client,
collection_name="index-collection")
qdrant_storage_context = StorageContext.from_defaults(vector_store=qdrant_vector_store)
# generate embeddings and set the index-id
vector_store_index = VectorStoreIndex.from_documents(docs,
storage_context=qdrant_storage_context)
vector_store_index.set_index_id("vector-store-index")
summary_index = SummaryIndex.from_documents(documents=docs,
storage_context=qdrant_storage_context)
summary_index.set_index_id("summary-index")
# Storing multiple indicies in one place
qdrant_storage_context.persist(persist_dir="./vector_store/db")
The above will be the Ingestion Part
Now in the Chat or Query Part, I need to retrieve the stored indicies and create the
RouterQueryEngine
.
I am doing this like below -
query.py
client = QdrantClient(path="./vector_store/db")
qdrant_vector_store = QdrantVectorStore(client= client,
collection_name="index-collection")
qdrant_storage_context = StorageContext.from_defaults(vector_store=qdrant_vector_store)
# load from the persisted data
from llama_index.core import load_index_from_storage, load_indices_from_storage
# create storage context
loaded_indices = load_indices_from_storage(storage_context=qdrant_storage_context,
index_ids=['vector-store-index', 'summary-index'])