Skip to content

Commit 88b50a8

Browse files
committed
remov Pipeline type
1 parent dab011f commit 88b50a8

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

source/aggregation/atlas-search.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ Search queries by using the Aggregation Builder:
6666
To create a ``$search`` stage in your aggregation pipeline, perform the
6767
following actions:
6868

69-
1. Create a ``Pipeline`` class instance to create the pipeline
69+
1. Create an array to store the pipeline stages
7070

71-
#. Within the ``Pipeline`` instance, call the ``Stage::search()`` method
72-
to create the Atlas Search stage
71+
#. Call the ``Stage::search()`` method to create the Atlas Search stage
7372

7473
#. Within the body of the ``search()`` method, use methods from the
7574
``Search`` builder class to construct your Search query criteria
@@ -79,12 +78,12 @@ queries:
7978

8079
.. code-block:: php
8180

82-
$pipeline = new Pipeline(
81+
$pipeline = [
8382
Stage::search(
8483
/* Atlas Search query specifications
8584
Search::compound(...) */
8685
),
87-
);
86+
];
8887

8988
Atlas Search Query Examples
9089
---------------------------

source/aggregation/vector-search.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ Search queries by using the Aggregation Builder:
6767
To create a ``$vectorSearch`` stage in your aggregation pipeline, perform the
6868
following actions:
6969

70-
1. Create a ``Pipeline`` class instance to create the pipeline
70+
1. Create an array to store the pipeline stages
7171

72-
#. Within the ``Pipeline`` instance, call the ``Stage::vectorSearch()`` method
73-
to create the Atlas Vector Search stage
72+
#. Call the ``Stage::vectorSearch()`` method to create the Atlas Vector
73+
Search stage
7474

7575
#. Within the body of the ``vectorSearch()`` method, specify the
7676
criteria for your vector query
@@ -80,13 +80,13 @@ queries:
8080

8181
.. code-block:: php
8282

83-
$pipeline = new Pipeline(
83+
$pipeline = [
8484
Stage::vectorSearch(
8585
/* Atlas Vector Search query specifications
8686
index: '<index name>',
8787
path: '<path to embeddings>', ...*/
8888
),
89-
);
89+
];
9090

9191
You must pass the following parameters to the ``vectorSearch()`` method:
9292

source/includes/aggregation/atlas-search.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

33
// start-imports
4-
use MongoDB\Builder\Pipeline;
54
use MongoDB\Builder\Search;
65
use MongoDB\Builder\Stage;
76
// end-imports
@@ -35,7 +34,7 @@
3534
echo "\n";
3635

3736
// start-compound-search-query
38-
$pipeline = new Pipeline(
37+
$pipeline = [
3938
Stage::search(
4039
Search::compound(
4140
must: [
@@ -64,9 +63,9 @@
6463
name: 1
6564
),
6665
Stage::limit(3)
67-
);
66+
];
6867

69-
$cursor = $collection->aggregate(iterator_to_array($pipeline));
68+
$cursor = $collection->aggregate($pipeline);
7069

7170
foreach ($cursor as $doc) {
7271
echo json_encode($doc), PHP_EOL;
@@ -110,7 +109,7 @@
110109
echo "\n";
111110

112111
// start-autocomplete-search-query
113-
$pipeline = new Pipeline(
112+
$pipeline = [
114113
Stage::search(
115114
Search::autocomplete(
116115
query: 'Lucy',
@@ -119,9 +118,9 @@
119118
),
120119
Stage::limit(3),
121120
Stage::project(_id: 0, name: 1),
122-
);
121+
];
123122

124-
$cursor = $collection->aggregate(iterator_to_array($pipeline));
123+
$cursor = $collection->aggregate($pipeline);
125124

126125
foreach ($cursor as $doc) {
127126
echo json_encode($doc), PHP_EOL;

source/includes/aggregation/vector-search.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

33
// start-imports
4-
use MongoDB\Builder\Pipeline;
54
use MongoDB\Builder\Stage;
65
// end-imports
76

@@ -43,7 +42,7 @@
4342
echo "\n";
4443

4544
// start-basic-query
46-
$pipeline = new Pipeline(
45+
$pipeline = [
4746
Stage::vectorSearch(
4847
index: 'vector',
4948
path: 'plot_embedding',
@@ -55,17 +54,17 @@
5554
_id: 0,
5655
title: 1,
5756
),
58-
);
57+
];
5958

60-
$cursor = $collection->aggregate(iterator_to_array($pipeline));
59+
$cursor = $collection->aggregate($pipeline);
6160

6261
foreach ($cursor as $doc) {
6362
echo json_encode($doc), PHP_EOL;
6463
}
6564
// end-basic-query
6665

6766
// start-score-query
68-
$pipeline = new Pipeline(
67+
$pipeline = [
6968
Stage::vectorSearch(
7069
index: 'vector',
7170
path: 'plot_embedding',
@@ -78,9 +77,9 @@
7877
title: 1,
7978
score: ['$meta' => 'vectorSearchScore'],
8079
),
81-
);
80+
];
8281

83-
$cursor = $collection->aggregate(iterator_to_array($pipeline));
82+
$cursor = $collection->aggregate($pipeline);
8483

8584
foreach ($cursor as $doc) {
8685
echo json_encode($doc), PHP_EOL;

0 commit comments

Comments
 (0)