The community member is following the FAISS vectorstore documentation and has successfully indexed documents, but is encountering issues with retrieval. They are getting a KeyError: '1' error when trying to query the index. The community members discuss potential solutions, such as checking how the index was saved, using index.insert_nodes(nodes) instead, and ensuring there are at least 10 nodes in the index store. The issue is eventually resolved, with the community member finding that the error was caused by having only one node in the index store, which is not enough for the query to work.
vector_store = FaissVectorStore.from_persist_dir(FAISS_INDEX_PATH)
storage_context = StorageContext.from_defaults(
vector_store=vector_store, persist_dir=FAISS_INDEX_PATH
)
# generate embeddings for each node
for node in nodes:
node_embedding = base_embeddings.get_text_embedding(
node.get_content(metadata_mode="all")
)
node.embedding = node_embedding
print(node_embedding)
# index the message in the vector db
vector_store.add(nodes)
index.storage_context.persist()
nope, same stuff.... Did you run the notebook on your local? or can you try to run the script above on your local to see if that's an environment issue from my side?
I found the issue. You need at least 10 nodes in your index store. Since I was only loading one document with one sentence only, it creates only one node and fails.