Skip to content

Commit dc813d1

Browse files
committed
Update builder test
1 parent b503fa1 commit dc813d1

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

tests/Builder/Stage/ScoreFusionStageTest.php

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace MongoDB\Tests\Builder\Stage;
66

77
use MongoDB\Builder\Pipeline;
8+
use MongoDB\Builder\Stage;
89
use MongoDB\Tests\Builder\PipelineTestCase;
910

1011
/**
@@ -14,8 +15,59 @@ class ScoreFusionStageTest extends PipelineTestCase
1415
{
1516
public function testExample(): void
1617
{
17-
$pipeline = new Pipeline();
18-
18+
$pipeline = new Pipeline(
19+
Stage::scoreFusion(
20+
input: [
21+
'pipelines' => [
22+
'searchOne' => [
23+
[
24+
'$vectorSearch' => [
25+
'index' => 'vector_index',
26+
'path' => 'plot_embedding',
27+
'queryVector' => [-0.0016261312, -0.028070757, -0.011342932],
28+
'numCandidates' => 150,
29+
'limit' => 10,
30+
],
31+
],
32+
],
33+
'searchTwo' => [
34+
[
35+
'$search' => [
36+
'index' => '<INDEX_NAME>',
37+
'text' => [
38+
'query' => '<QUERY_TERM>',
39+
'path' => '<FIELD_NAME>',
40+
],
41+
],
42+
],
43+
],
44+
],
45+
'normalization' => 'sigmoid',
46+
],
47+
combination: [
48+
'method' => 'expression',
49+
'expression' => [
50+
'$sum' => [
51+
[
52+
'$multiply' => [
53+
'$$searchOne',
54+
10,
55+
],
56+
],
57+
'$$searchTwo',
58+
],
59+
],
60+
],
61+
scoreDetails: true,
62+
),
63+
Stage::project(
64+
_id: 1,
65+
title: 1,
66+
plot: 1,
67+
scoreDetails: ['$meta' => 'scoreDetails'],
68+
),
69+
Stage::limit(20),
70+
);
1971
$this->assertSamePipeline(Pipelines::ScoreFusionExample, $pipeline);
2072
}
2173
}

0 commit comments

Comments
 (0)