----------------------
Based on the information provided in the knowledge sources, the
insert
method is used to add new documents to an existing index. However, the underlying mechanism behind insertion depends on the index structure. For the vector store index, a new Document (and embeddings) is inserted into the underlying document/embedding store.
Here is an example of how to insert documents into an index:
from llama_index.core import VectorStoreIndex
index = VectorStoreIndex([])
for doc in documents:
index.insert(doc)
(Source:
LlamaIndex > En > Latest > Understanding > Storing > Storing > Inserting Documents or Nodes ())
However, it's important to note that if you're using a Vector Store Index, you should use the
from_documents
method to build the index from a list of documents:
from llama_index.core import VectorStoreIndex
index = VectorStoreIndex.from_documents(documents)
(Source:
LlamaIndex > En > Latest > Understanding > Indexing > Indexing > Vector Store Index > Using Vector Store Index ())
If you're adding data to an existing index, you can use the
from_documents
method and pass the URI of your existing index:
index = VectorStoreIndex.from_documents(documents, uri="/tmp/new_dataset")
(Source:
Jerryjliu > Llama_index > Blob > Main > Docs > Docs > Examples > Vector_stores > LanceDB Vector Store > Appending data ())