run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
36.71k stars 5.26k forks source link

[Bug]: Creating VectorStoreIndex from VectorStore does NOT build the index #16957

Open ErikVogelLUH opened 7 hours ago

ErikVogelLUH commented 7 hours ago

Bug Description

When a VectorStoreIndex is created, it builds an index from the nodes which are supplied in the constructor. When I want to create a VectorStoreIndex from a VectorStore via VectorStoreIndex.from_vector_store, the node argument of the constructor for the VectorStoreIndex is set to []. Instead the VectorStore is put in a StorageContext which is give to the Index, but the index does not use the Context to build its Index. You have to manually call build_index_from_nodes even though the nodes are already there

Version

0.11.20

Steps to Reproduce

vector_store=SimpleVectorStore() vector_store.add(nodes) index=VectorStoreIndex.from_vector_store(vector_store)

Relevant Logs/Tracbacks

No response

logan-markewich commented 7 hours ago

@ErikVogelLUH that is expected. This is a shortcut to connect to a vector index you already created with llama-index

dosubot[bot] commented 7 hours ago

Hey @ErikVogelLUH! 👋 I'm here to help you with any bugs, questions, or contributions.

I found a similar unsolved discussion that might be related to your issue: VectorStoreIndex has empty index because its vectorstore stores_text attribute is true, which was last updated on July 16, 2024 [1].

Regarding your issue, when using the VectorStoreIndex.from_vector_store method, it is expected that the index is initialized from the existing vector store, provided that the vector store stores text. However, it seems that the method does not automatically build the index from the nodes in the vector store, and you need to manually call build_index_from_nodes to complete the process [2].

To continue talking to Dosu, mention @dosu.

logan-markewich commented 7 hours ago

90% of vector stores store the nodes in the vector store, so that's all you need to "rebuild" the index

ErikVogelLUH commented 7 hours ago

How do I properly build the index from the StorageContext?