VectorIndexConfig#

class langgraph.store.mongodb.base.VectorIndexConfig[source]#

Configuration for a MongoDB Atlas Vector Index providing semantic search.

Use the factory function, ~langgraph.store.mongodb.create_vector_index_config for convenient creation and sensible defaults.

Unlike PostgreSQL, MongoDB does not require a separate package or vector store. Embeddings are stored and indexed within the collection that holds the data. For more: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview

Vector Search can be Approximate Nearest Neighbor (ANN) or Exact (ENN). For ANN, Atlas uses HNSW (Hierarchical Navigable Small World).

dims: int#
embed: Embeddings | Callable[[Sequence[str]], list[list[float]]] | Callable[[Sequence[str]], Awaitable[list[list[float]]]] | str#
fields: list[str] | None#
name: str#

Name of the index attached to the Collection in the Atlas Database.

relevance_score_fn: Literal['euclidean', 'cosine', 'dotProduct', None]#

Similarity scoring function used to compare vectors.

embedding_key: str#

This key will contain the embedding vector for the value in fields[0].

MongoDB does not require a separate Vector Store. It is designed to have one vector per document.

NOTE: If using AutoEmbeddings, the vectors are not explicitly stored in the Collection. Set dims to -1, relevance_score_fn to None. The embedding_key will not store vectors. Instead, it will be the texts to be embedded.

filters: list[str]#

List of fields to that can filtered during search.

Fields must be included in the index if they are to be filtered upon. The namespace field will always be included. These will be added to the vector search index automatically if not present.

Fields can refer to top-level or embedded values (e.g. metadata.available)

NOTE: The value key at the front of every field is implicit. It need not be included, although it is contained in the collection and index.