Skip to main content

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:
Issue a semantic query using similarity_search, which returns the closest embedded documents:
Many vector stores support parameters like:
  • k — number of results to return
  • filter — 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:

Top integrations

Select embedding model:
For more information, see the Voyage AI documentation.
Select vector store:
pip
Install the package and start Elasticsearch locally using the start-local script:
This creates an elastic-start-local folder. To start Elasticsearch:
Elasticsearch will be available at http://localhost:9200. The password for the elastic user and API key are stored in the .env file in the elastic-start-local folder.
For more information, see the MongoDB LangChain integration docs.

All vector stores

Activeloop Deep Lake

Alibaba Cloud MySQL

Astra DB Vector Store

Azure Cosmos DB Mongo vCore

Azure Cosmos DB No SQL

Azure Database for PostgreSQL - Flexible Server

CockroachDB

Couchbase

Databricks

IBM Db2

Amazon Document DB

Elasticsearch

Gel

Google AlloyDB

Google BigQuery Vector Search

Google Cloud SQL for MySQL

Google Cloud SQL for PostgreSQL

Firestore

Google Memorystore for Redis

Google Spanner

Google Bigtable

Google Vertex AI Feature Store

Google Vertex AI Vector Search

Kinetica

LambdaDB

Lindorm

Amazon MemoryDB

Milvus

Moorcheh

MongoDB Atlas

Oceanbase

openGauss

Oracle AI Database

PGVectorStore

Pinecone

Pinecone (sparse)

Qdrant

Redis

SAP HANA Cloud Vector Engine

SQLServer

SurrealDB

Teradata VectorStore

Valkey

VDMS

veDB for MySQL

Volcengine RDS for MySQL

Weaviate

YDB

ZeusDB