Find answers from the community

Updated 3 months ago

How to get an existing index? (without

How to get an existing index? (without creating it)


Plain Text
service_context = ServiceContext.from_defaults()
vector_store = QdrantVectorStore(client=client, collection_name="paul_graham")
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(
    documents, storage_context=storage_context, service_context=service_context
)
query_engine = index.as_query_engine()
response = query_engine.query("What did the author do growing up?")


Here, we are using from_documents, which inserts new data. But how do I get an existing index, If I reboot the app for example? I don't want to re-create the index again
N
p
6 comments
Here is something that i did with local storage
storage_context = StorageContext.from_defaults(persist_dir="./storage")
index = load_index_from_storage(storage_context, service_context=service_context)
Thanks @NPC_Kenny . I couldn't find info about that in the docs
I am using chroma (also local )
vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
this works as well for using chromadb I am sure they have hooks for other db and they work in a similar fashion
You are welcome. Good luck with your application
It is not working and I'm confused now.

I did not use StorageContext when I persisted my data. I used IngestionPipeline , which doesn't require an index, but a vector store itself.

I can see that my embeddings been persisted. Now I don't know how to connect to that local vector store using this pattern:

Plain Text
    question = "What are the company's climate change targets?"

    query_engine = index.as_query_engine(similarity_top_k=3)

    response = query_engine.query(question)
    return response


Where do I get index?
index = VectorStoreIndex.from_vector_store(
vector_store,
service_context=service_context,
)
Add a reply
Sign up and join the conversation on Discord