Skip to content

Commit a16b282

Browse files
authored
feat(mongodb-constants): add $scoreFusion stage operator COMPASS-9430 (#576)
add $scoreFusion stage operator
1 parent cbd256e commit a16b282

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

packages/mongodb-constants/src/stage-operators.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,54 @@ const STAGE_OPERATORS = [
883883
`,
884884
snippet: `{
885885
size: \${1:number}
886+
}`,
887+
},
888+
{
889+
name: '$scoreFusion',
890+
value: '$scoreFusion',
891+
label: '$scoreFusion',
892+
outputStage: false,
893+
fullScan: false,
894+
firstStage: false,
895+
score: 1,
896+
env: [ATLAS],
897+
meta: 'stage',
898+
version: '8.2.0',
899+
apiVersions: [],
900+
namespaces: [COLLECTION],
901+
description:
902+
'Combines multiple pipelines using relative score fusion to create hybrid search results.',
903+
comment: `/**
904+
* input.pipelines: Required. Map from name to input pipeline. Each pipeline must be operating on the same collection. Minimum of one pipeline.
905+
* input.normalization: Required. Normalizes the score to the range 0 to 1 before combining the results. Value can be none, sigmoid or minMaxScaler.
906+
* combination.weights: Optional. Map from pipeline name to numbers (non-negative). If unspecified, default weight is 1 for each pipeline.
907+
* combination.method: Optional. Specifies method for combining scores. Value can be avg or expression. Default is avg.
908+
* combination.expression: Optional. This is the custom expression that is used when combination.method is set to expression.
909+
* scoreDetails: Optional. Default false. Set to true to include detailed scoring information.
910+
*/
911+
`,
912+
snippet: `{
913+
input: {
914+
pipelines: {
915+
\${1:searchPipeline}: [
916+
{$search: {\${2:searchStage}}},
917+
{$limit: \${3:limit}}
918+
],
919+
\${4:vectorPipeline}: [
920+
{$vectorSearch: {\${5:vectorSearchStage}}}
921+
]
922+
},
923+
normalization: '\${6:none|sigmoid|minMaxScaler}'
924+
},
925+
combination: {
926+
weights: {
927+
\${7:searchPipeline}: \${8:number},
928+
\${9:vectorPipeline}: \${10:number}
929+
},
930+
method: '\${11:avg|expression}',
931+
expression: '\${12:expression}'
932+
},
933+
scoreDetails: \${13:false}
886934
}`,
887935
},
888936
{

0 commit comments

Comments
 (0)