RerankConfig#

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

Configuration for native reranking via the $rerank aggregation stage.

Reranking runs entirely server-side on MongoDB Atlas — no Voyage AI SDK or client-side API key is required. Atlas calls the Voyage AI reranker API on your behalf using a key you configure in Atlas Project Settings.

Prerequisites (all must be satisfied before results are reranked):
  1. MongoDB Atlas cluster running MongoDB 8.3+.

  2. Native Reranking enabled in Atlas Project Settings.

  3. A Voyage AI API key configured in Atlas Project Settings.

If any prerequisite is missing, search() will return constant scores (e.g. 0.5987) for all documents rather than raising an error.

model#

Voyage AI reranking model (e.g. "rerank-2.5-lite"). Omit to use the latest available model.

Type:

str

num_docs_to_rerank#

Number of candidates passed from $vectorSearch to the reranker. Must be >= the limit passed to search() and <= 1000 (the MongoDB maximum for $rerank). Defaults to min(limit * oversampling_factor, 1000), which satisfies both constraints as long as limit itself is <= 1000. Passing limit > 1000 with reranking enabled raises a ValueError at search time.

Type:

int

oversampling_factor#

Multiplier applied to limit when computing the default num_docs_to_rerank. Ignored when num_docs_to_rerank is set explicitly. Defaults to 10.

Type:

int

model: str#
num_docs_to_rerank: int#
oversampling_factor: int#