Skip to content

feat(mongodb-constants): add $rankFusion stage for 8.1+ COMPASS-9429 #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions packages/mongodb-constants/src/stage-operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,48 @@ const STAGE_OPERATORS = [
`,
snippet: `{
\${1:specification(s)}
}`,
},
{
name: '$rankFusion',
value: '$rankFusion',
label: '$rankFusion',
outputStage: false,
fullScan: false,
firstStage: false,
score: 1,
env: [ATLAS],
meta: 'stage',
version: '8.1.0',
apiVersions: [],
namespaces: [COLLECTION],
description:
'Combines multiple pipelines using reciprocal rank fusion to create hybrid search results.',
comment: `/**
* input.pipelines: Required. Map from name to input pipeline. Each pipeline must be a Ranked Selection Pipeline operating on the same collection. Minimum of one pipeline.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@Anemy Anemy Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't provide explicit links inside of the comment for any of the other stages, so I would prefer we keep that pattern if we can. We link to the stage's documentation in the aggregation builder, so folks can find it there:
Screenshot 2025-06-16 at 4 41 39 PM
Is that link enough? If we feel strongly we can change it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that works!

* combination.weights: Optional. Map from pipeline name to numbers (non-negative). If unspecified, default weight is 1 for each pipeline.
* scoreDetails: Optional. Default false. Set to true to include detailed scoring information in {$meta: "scoreDetails"} for debugging and tuning.
*/
`,
snippet: `{
input: {
pipelines: {
\${1:searchPipeline}: [
{$search: {\${2:searchStage}}},
{$limit: \${3:limit}}
],
\${4:vectorPipeline}: [
{$vectorSearch: {\${5:vectorSearchStage}}}
]
}
},
combination: {
weights: {
\${6:searchPipeline}: \${7:number},
\${8:vectorPipeline}: \${9:number}
}
},
scoreDetails: \${10:false}
}`,
},
{
Expand Down