reciprocal_rank_stage#

langchain_mongodb.pipelines.reciprocal_rank_stage(
score_field: str,
penalty: float = 0,
weight: float = 1,
**kwargs: Any,
) → List[Dict[str, Any]][source]#

Stage adds Weighted Reciprocal Rank Fusion (WRRF) scoring.

First, it groups documents into an array, assigns rank by array index, and then computes a weighted RRF score.

Parameters:
  • score_field (str) – A unique string to identify the search being ranked.

  • penalty (float) – A non-negative float (e.g., 60 for RRF-60). Controls the denominator.

  • weight (float) – A float multiplier for this source’s importance.

  • **kwargs (Any) – Ignored; allows future extensions or passthrough args.

Returns:

Aggregation pipeline stage for weighted RRF scoring.

Return type:

List[Dict[str, Any]]