LlamaIndex Indexing
Index design determines whether retrieval finds useful evidence. Poorly prepared documents can look like a generation problem later.
#Documents and nodes
A Document is divided into Nodes. A node can carry text, file/page information and relationships. It is a unit for retrieval, filtering, citations and source tracing—not just a string fragment.
#Index choices
VectorStoreIndex embeds nodes for semantic retrieval. SummaryIndex keeps a sequence useful for document-wide synthesis. TreeIndex represents hierarchical organization. KeywordTableIndex supports term-oriented lookup. Check the installed version before choosing an integration.
#Persist and reload
pythonindex.storage_context.persist(persist_dir="./storage") from llama_index.core import StorageContext, load_index_from_storage storage_context = StorageContext.from_defaults(persist_dir="./storage") index = load_index_from_storage(storage_context)
#Connect a vector store
pythonimport chromadb from llama_index.core import StorageContext, VectorStoreIndex from llama_index.vector_stores.chroma import ChromaVectorStore db = chromadb.PersistentClient(path="./chroma_db") collection = db.get_or_create_collection("my_data") vector_store = ChromaVectorStore(chroma_collection=collection) storage_context = StorageContext.from_defaults(vector_store=vector_store) index = VectorStoreIndex.from_documents( documents, storage_context=storage_context )
This fragment assumes documents, provider configuration and compatible integration packages already exist.
#Improve the foundation first
Small chunks can lose context; large chunks can introduce noise and cost. Treat defaults as a starting point. Add useful metadata such as section/source identifiers and evaluate representative queries before changing index types repeatedly.