[Question]: Persisting (and loading) index from Neo4j #8407
Replies: 4 comments 5 replies
-
🤖 Hello, To load an index after building it using Neo4J in the LlamaIndex framework, you can use the Here is the relevant code: from llama_index.indices.loading import load_index_from_storage
from llama_index.storage.storage_context import StorageContext
# create a storage context
storage_context = StorageContext(docstore, index_store, vector_store)
# load the index
index = load_index_from_storage(storage_context, index_id='your_index_id') In this code, Please note that the If no indices are returned, it raises a ValueError stating "No index in storage context, check if you specified the right persist_dir." If more than one index is returned, it raises a ValueError stating "Expected to load a single index, but got {len(indices)} instead. Please specify index_id." If exactly one index is returned, it returns that index. I hope this helps! Let me know if you have any other questions. Best, Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
I'm getting the message "No index in storage context, check if you specified the right persist_dir." from my code:
after persisting the index:
and I'm pretty sure my credentials are right (username = neo4j, password = the password when I created my account, url is copy and pasted from the neo4j console with the port, database = neo4j). Do I need to use bolt here? but it's probably an issue with my neo4j creds. Can I have some help with these?
|
Beta Was this translation helpful? Give feedback.
-
Would love some guidance here. Added a test function to my file, so it appears my credentials are correct but my llamaindex code is not.
|
Beta Was this translation helpful? Give feedback.
-
Similar situation when using ChromaDB. The SQLite is populated, I have the file, built the context with the vector store, but can't load the index: chroma_client = chromadb.PersistentClient("chroma.db")
chroma_collection = chroma_client.get_or_create_collection("my_collection")
vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = load_index_from_storage(storage_context=storage_context) I had initially built the index with the storage context (using the storage_context = StorageContext.from_defaults(vector_store=vector_store)
service_context = ServiceContext.from_defaults(embed_model=embed_model)
index = VectorStoreIndex(index_struct=IndexDict(), storage_context=storage_context, service_context=service_context) And then added the nodes to the index with |
Beta Was this translation helpful? Give feedback.
-
Question Validation
Question
I assume you do not have to persist an index after building it using Neo4J... but how do you load the index in?
TY
Beta Was this translation helpful? Give feedback.
All reactions