Overview
A vector stores embedded data and performs similarity search.
Interface
LangChain provides a unified interface for vector stores, allowing you to:
add_documents- Add documents to the store.delete- Remove stored documents by ID.similarity_search- Query for semantically similar documents.
This abstraction lets you switch between different implementations without altering your application logic.
Initialization
To initialize a vector store, provide it with an embedding model:
Adding documents
Add Document objects (holding page_content and optional metadata) like so:
Deleting documents
Delete by specifying IDs:
Similarity search
Issue a semantic query using similarity_search, which returns the closest embedded documents:
Many vector stores support parameters like:
k— number of results to returnfilter— conditional filtering based on metadata
Similarity metrics & indexing
Embedding similarity may be computed using:
- Cosine similarity
- Euclidean distance
- Dot product
Efficient search often employs indexing methods such as HNSW (Hierarchical Navigable Small World), though specifics depend on the vector store.
Metadata filtering
Filtering by metadata (e.g., source, date) can refine search results:
Select embedding model:
Select vector store:
| Vectorstore | Delete by ID | Filtering | Search by Vector | Search with score | Async | Passes Standard Tests | Multi Tenancy | IDs in add Documents | Downloads |
|---|---|---|---|---|---|---|---|---|---|
ValkeyVectorStore | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | |
DatabricksVectorSearch | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | |
PineconeVectorStore | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | |
MongoDBAtlasVectorSearch | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
AzureCosmosDBMongoVCoreVectorStore | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | |
QdrantVectorStore | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | |
Milvus | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
Weaviate | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | |
ElasticsearchStore | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | |
AstraDBVectorStore | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
Oracle AI Database | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | |
RedisVectorStore | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | |
AzureCosmosDBNoSqlVectorStore | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | |
Google AlloyDB | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | |
InMemoryVectorStore | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ | ✅ | N/A |