Find answers from the community

Updated 3 months ago

Can I combine multiple indexes into one vector index?

Can I combine multiple indexes into one vector index?
k
L
n
4 comments
Please stand by @node0 as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
Based on the information provided in the knowledge sources, it is not explicitly stated that you can combine multiple indexes into one vector index. However, it is mentioned that each index uses the same underlying Node and that you can build a separate vector index per city or choose to define a single vector index across all documents, annotating each chunk by metadata.

Here is an example of how to create multiple indexes:

Plain Text
summary_index = SummaryIndex(nodes, storage_context=storage_context)
vector_index = VectorStoreIndex(nodes, storage_context=storage_context)
keyword_table_index = SimpleKeywordTableIndex(nodes, storage_context=storage_context)

And here is an example of how to build a separate vector index per document (city in this case):

Plain Text
vector_indices = []
for wiki_doc in wiki_docs:
    vector_index = VectorStoreIndex.from_documents([wiki_doc])
    vector_indices.append(vector_index)

These examples suggest that while you can create multiple indexes and build separate vector indexes for different sets of documents, there is no direct mention of combining multiple indexes into one vector index.

For more detailed information, you may want to refer to the official documentation or source code of LlamaIndex.

Sources:
  • LlamaIndex > En > Latest > Examples > Docstore > Docstore Demo> Define Multiple Indexes ()
  • Jerryjliu > Llama_index > Blob > Main > Docs > Docs > Examples > Query_engine > SQL Router Query Engine > Build Vector Index ()
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
No, you must query each index and than eccumulate the responses if you want to.
Okay, thank you @Leonardo Oliva
Add a reply
Sign up and join the conversation on Discord