Repository navigation
Add $rankFusion stage and $sigmoid expression - #32
Conversation
There was a problem hiding this comment.
Pull request overview
Adds new MongoDB 8.1 operator definitions to the repository’s YAML-based operator catalog to support Vector Search Hybrid Scoring (featureFlagRankFusionBasic).
Changes:
- Added
$rankFusionaggregation stage definition, including an example pipeline test. - Added
$sigmoidaggregation expression definition, including an example pipeline test + schema.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| definitions/stage/rankFusion.yaml | Introduces the $rankFusion stage spec (v8.1+) with arguments and an example usage. |
| definitions/expression/sigmoid.yaml | Introduces the $sigmoid expression spec (v8.1+) with argument typing and an example usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
These operators are introduced in MongoDB 8.1 as part of the featureFlagRankFusionBasic milestone (SERVER-97919). - $rankFusion: Aggregation stage that combines multiple pipelines using rank-based fusion to create hybrid search results. - $sigmoid: Expression that returns 1 / (1 + e^(-x)), mapping any numeric input to a value between 0 and 1.
e8d3b0b to
a985640
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| scoreDetails: true | ||
| - $addFields: | ||
| scoreDetails: | ||
| $meta: searchScoreDetails |
There was a problem hiding this comment.
In the example pipeline, the $meta keyword is set to searchScoreDetails, but in this repo $scoreFusion uses $meta: scoreDetails when scoreDetails: true is enabled. If $rankFusion also exposes its details via the scoreDetails meta keyword (as the option name suggests), this example will be incorrect/misleading—please confirm against the server behavior/docs and align the meta keyword (and/or field name) accordingly.
| $meta: searchScoreDetails | |
| $meta: scoreDetails |
There was a problem hiding this comment.
Copied from https://www.mongodb.com/docs/manual/reference/operator/aggregation/rankFusion/#examples
const pipeline = [
{
$rankFusion: {
input: {
pipelines: {
searchPlot: [
{
$search: {
index: "default",
text: { query: "space", path: "plot"}
}
}
],
searchGenre: [
{
$search: {
index: "default",
text: { query: "adventure", path: "genres" }
}
}
]
}
},
combination: { weights: {searchPlot: 0.6, searchGenre: 0.4} },
scoreDetails: true
}
},
{ $addFields: { scoreDetails: { $meta: "searchScoreDetails" } } }
];
const cursor = collection.aggregate(pipeline);
return cursor;| arguments: | ||
| - name: input | ||
| type: | ||
| - object |
There was a problem hiding this comment.
This should be expressed with a more advanced type system.
Summary
$rankFusionaggregation stage definition (MongoDB 8.1+,featureFlagRankFusionBasic)$sigmoidexpression definition (MongoDB 8.1+,featureFlagRankFusionBasic)Both operators are introduced as part of the Vector Search Hybrid Scoring milestone (SERVER-97919 /
featureFlagRankFusionBasic).$rankFusion
Combines multiple pipelines using rank-based fusion to create hybrid search results. Accepts:
input.pipelines: Map from name to ranked input pipelinecombination.weights(optional): Map from pipeline name to weight valuesscoreDetails(optional, defaultfalse): Include detailed scoring information$sigmoid
Returns the sigmoid of a numeric value:
1 / (1 + e^(-x)). Maps any numeric input to a value between 0 and 1.References