Vector Store Overview
A vector store persists embedded chunks and answers nearest-neighbour queries. Every implementation in this folder — Chroma, FAISS, pgvector, Pinecone — sits behind the same VectorStore interface, so swapping the backend later is mostly a constructor change, not a rewrite.
from langchain_core.documents import Document
documents = [
Document(page_content="LangChain composes LLM calls into chains.", metadata={"source": "intro"}),
Document(page_content="A retriever returns the chunks most relevant to a query.", metadata={"source": "intro"}),
]
ids = vector_store.add_documents(documents)
results = vector_store.similarity_search("what does a retriever do?", k=1)
retriever = vector_store.as_retriever(search_type="similarity", search_kwargs={"k": 4})
The shared surface
| Method | Does |
|---|---|
from_documents(docs, embedding, ...) | Build a new store from Documents in one call |
add_documents(docs) | Index more chunks into an existing store |
similarity_search(query, k) | Return the k nearest chunks to a query |
as_retriever(search_type, search_kwargs) | Wrap the store as a Retriever Runnable (Retrievers) |
Index lifecycle
Re-indexing — not updating — is what you do after changing the embedding model or the chunking strategy, since neither is comparable to what's already stored (Embeddings).
Key idea
The pages that follow differ mainly in setup and filtering syntax, not in how you call them. Once you know similarity_search and as_retriever, moving from Chroma to pgvector is a config change.
See also
- Retrievers — search strategies layered on top of
as_retriever. - Comparison — which store to pick for a given workload.