Skip to content

Commit 9d4aae2

Browse files
committed
JT tech review 1
1 parent d912397 commit 9d4aae2

File tree

5 files changed

+266
-123
lines changed

5 files changed

+266
-123
lines changed

source/aggregation.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Consider the following limitations when performing aggregation operations:
7777
and passing the array to the ``MongoDB\Collection::aggregate()`` method.
7878

7979
.. important:: $graphLookup Exception
80-
80+
8181
The :manual:`$graphLookup
8282
</reference/operator/aggregation/graphLookup/>` stage has a strict
8383
memory limit of 100 megabytes and ignores the ``allowDiskUse`` option.

source/aggregation/atlas-search.txt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,7 @@ to perform queries. To learn more about this operator, see the
3939
:atlas:`$search </atlas-search/aggregation-stages/search/>` reference in
4040
the Atlas documentation.
4141

42-
.. note::
43-
44-
You might not be able to use the methods described in this guide for
45-
every type of Atlas Search query. For more complex use cases, you can
46-
create standard aggregation pipelines. To learn more, see the
47-
:ref:`php-aggregation` guide.
42+
.. note:: Atlas Vector Search
4843

4944
To perform searches on vector embeddings in MongoDB, you can use the
5045
Atlas Vector Search API. To learn about this feature, see
@@ -63,11 +58,11 @@ Search Aggregation Stage
6358
Import the following classes into your application to perform Atlas
6459
Search queries by using the Aggregation Builder:
6560

66-
.. code-block:: php
67-
68-
use MongoDB\Builder\Pipeline;
69-
use MongoDB\Builder\Search;
70-
use MongoDB\Builder\Stage;
61+
.. literalinclude:: /includes/aggregation/atlas-search.php
62+
:language: php
63+
:dedent:
64+
:start-after: start-imports
65+
:end-before: end-imports
7166

7267
To create a ``$search`` stage in your aggregation pipeline, perform the
7368
following actions:
@@ -84,7 +79,7 @@ The following code demonstrates the template for constructing basic Atlas Search
8479
queries:
8580

8681
.. code-block:: php
87-
82+
8883
$pipeline = new Pipeline(
8984
Stage::search(
9085
/* Atlas Search query specifications
@@ -132,8 +127,9 @@ specifications:
132127
:language: json
133128
:visible: false
134129

135-
{"_id": ...,"borough":"Queens","cuisine":"American","name":"Suite Kitchen",...}
136-
{"_id": ...,"borough":"Queens","cuisine":"American","name":"Silver Kitchen",...}
130+
{"_id":...,"borough":"Queens","cuisine":"American","name":"Kitchen Door"}
131+
{"_id":...,"borough":"Queens","cuisine":"American","name":"Cc Kitchen"}
132+
{"_id":...,"borough":"Queens","cuisine":"American","name":"Suite Kitchen"}
137133
// Results truncated
138134

139135
Autocomplete Query
@@ -169,9 +165,9 @@ string ``"Lucy"`` on the ``name`` field:
169165
:language: json
170166
:visible: false
171167

172-
{"name":"Lucy'S Asian Kitchen"}
173-
{"name":"Lucy'S Cantina Royale"}
168+
{"name":"Juicy Lucy"}
174169
{"name":"Lucy'S Vietnamese Kitchen"}
170+
{"name":"Lucy'S Cantina Royale"}
175171
// Results Truncated
176172

177173
You can also pass the following optional parameters to the ``autocomplete()``

source/aggregation/vector-search.txt

Lines changed: 68 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ perform Atlas Vector Search queries by using the :ref:`Aggregation Builder API
2727

2828
.. note:: Deployment Compatibility
2929

30-
You can use the Atlas Search feature only when
31-
you connect to MongoDB Atlas clusters. This feature is not
32-
available for self-managed deployments.
30+
You can use the Atlas Search feature only when
31+
you connect to MongoDB Atlas clusters. This feature is not
32+
available for self-managed deployments.
3333

3434
To learn more about Atlas Vector Search, see the :atlas:`Overview
3535
</atlas-vector-search/vector-search-overview/>` in the
@@ -40,12 +40,7 @@ to perform queries. To learn more about this operator, see the
4040
</atlas-vector-search/vector-search-stage/#syntax>` reference in the
4141
Atlas documentation.
4242

43-
.. note::
44-
45-
You might not be able to use the methods described in this guide for
46-
every type of Atlas Vector Search query. For more complex use cases, you can
47-
create standard aggregation pipelines. To learn more, see the
48-
:ref:`php-aggregation` guide.
43+
.. note:: Atlas Search
4944

5045
To perform advanced full-text search on your documents, you can use the
5146
Atlas Search API. To learn about this feature, see the
@@ -64,11 +59,11 @@ Vector Search Aggregation Stage
6459
Import the following classes into your application to perform Atlas
6560
Search queries by using the Aggregation Builder:
6661

67-
.. code-block:: php
68-
69-
use MongoDB\Builder\Pipeline;
70-
use MongoDB\Builder\Query;
71-
use MongoDB\Builder\Stage;
62+
.. literalinclude:: /includes/aggregation/vector-search.php
63+
:language: php
64+
:dedent:
65+
:start-after: start-imports
66+
:end-before: end-imports
7267

7368
To create a ``$vectorSearch`` stage in your aggregation pipeline, perform the
7469
following actions:
@@ -87,11 +82,11 @@ queries:
8782
.. code-block:: php
8883

8984
$pipeline = new Pipeline(
90-
Stage::vectorSearch(
91-
/* Atlas Vector Search query specifications
92-
index: '<index name>',
93-
path: '<path to embeddings>', ...*/
94-
),
85+
Stage::vectorSearch(
86+
/* Atlas Vector Search query specifications
87+
index: '<index name>',
88+
path: '<path to embeddings>', ...*/
89+
),
9590
);
9691

9792
You must pass the following parameters to the ``vectorSearch()`` method:
@@ -100,24 +95,24 @@ You must pass the following parameters to the ``vectorSearch()`` method:
10095
:header-rows: 1
10196

10297
* - Parameter
103-
- Type
104-
- Description
98+
- Type
99+
- Description
105100

106101
* - ``index``
107-
- ``string``
108-
- Name of the vector search index
102+
- ``string``
103+
- Name of the vector search index
109104

110105
* - ``path``
111-
- ``array`` or ``string``
112-
- Field that stores vector embeddings
106+
- ``array`` or ``string``
107+
- Field that stores vector embeddings
113108

114109
* - ``queryVector``
115-
- ``array``
116-
- Vector representation of your query
110+
- ``array``
111+
- Vector representation of your query
117112

118113
* - ``limit``
119-
- ``int``
120-
- Number of results to return
114+
- ``int``
115+
- Number of results to return
121116

122117
Atlas Search Query Examples
123118
---------------------------
@@ -127,6 +122,16 @@ Search queries by using the Aggregation Builder. The examples in this
127122
section use sample data from the ``sample_mflix.embedded_movies``
128123
collection.
129124

125+
.. note:: Query Vector Length
126+
127+
For demonstrative purposes, the examples in this section use
128+
sample query vectors that contain very few elements, compared to
129+
the query vector you might use in a runnable application. To view an
130+
example that contains the full-length query vector, see the
131+
:ref:`Atlas Vector Search Quick Start </atlas-vector-search/tutorials/vector-search-quick-start/>`
132+
and select :guilabel:`PHP` from the :guilabel:`Select your language` dropdown in the upper-right
133+
corner of the page.
134+
130135
Basic Vector Search Query
131136
~~~~~~~~~~~~~~~~~~~~~~~~~
132137

@@ -137,19 +142,19 @@ The following code performs an Atlas Vector Search query on the
137142
:copyable: true
138143

139144
.. input:: /includes/aggregation/vector-search.php
140-
:language: php
141-
:dedent:
142-
:start-after: start-basic-query
143-
:end-before: end-basic-query
145+
:language: php
146+
:dedent:
147+
:start-after: start-basic-query
148+
:end-before: end-basic-query
144149

145150
.. output::
146-
:language: json
147-
:visible: false
151+
:language: json
152+
:visible: false
148153

149-
{"_id": ...,"title":"About Time",...}
150-
{"_id": ...,"title":"Tomorrowland",...}
151-
{"_id": ...,"title":"Timecop",...}
152-
// Results truncated
154+
{"title":"Thrill Seekers"}
155+
{"title":"About Time"}
156+
{"title":"Timecop"}
157+
// Results truncated
153158

154159
Vector Search Score
155160
~~~~~~~~~~~~~~~~~~~
@@ -162,19 +167,19 @@ field, which describes how well the document matches the query vector:
162167
:copyable: true
163168

164169
.. input:: /includes/aggregation/vector-search.php
165-
:language: php
166-
:dedent:
167-
:start-after: start-score-query
168-
:end-before: end-score-query
170+
:language: php
171+
:dedent:
172+
:start-after: start-score-query
173+
:end-before: end-score-query
169174

170175
.. output::
171-
:language: json
172-
:visible: false
176+
:language: json
177+
:visible: false
173178

174-
{"title":"About Time","score":0.7843604683876038}
175-
{"title":"Timecop","score":0.7771612405776978}
176-
{"title":"Tomorrowland","score":0.7669923901557922}
177-
// Results truncated
179+
{"title":"Thrill Seekers","score":0.927734375}
180+
{"title":"About Time","score":0.925750732421875}
181+
{"title":"Timecop","score":0.9241180419921875}
182+
// Results truncated
178183

179184
Vector Search Options
180185
~~~~~~~~~~~~~~~~~~~~~
@@ -187,26 +192,26 @@ following optional parameters to ``vectorSearch()``:
187192
:header-rows: 1
188193

189194
* - Optional Parameter
190-
- Type
191-
- Description
192-
- Default Value
195+
- Type
196+
- Description
197+
- Default Value
193198

194199
* - ``exact``
195-
- ``bool``
196-
- Specifies whether to run an Exact Nearest Neighbor (``true``) or
197-
Approximate Nearest Neighbor (``false``) search
198-
- ``false``
200+
- ``bool``
201+
- Specifies whether to run an Exact Nearest Neighbor (``true``) or
202+
Approximate Nearest Neighbor (``false``) search
203+
- ``false``
199204

200205
* - ``filter``
201-
- ``QueryInterface`` or ``array``
202-
- Specifies a pre-filter for documents to search on
203-
- no filtering
206+
- ``QueryInterface`` or ``array``
207+
- Specifies a pre-filter for documents to search on
208+
- no filtering
204209

205210
* - ``numCandidates``
206-
- ``int`` or ``null``
207-
- Specifies the number of nearest neighbors to use during the
208-
search
209-
- ``null``
211+
- ``int`` or ``null``
212+
- Specifies the number of nearest neighbors to use during the
213+
search
214+
- ``null``
210215

211216
To learn more about these parameters, see the :atlas:`Fields
212217
</atlas-vector-search/vector-search-stage/#fields>` section of the

0 commit comments

Comments
 (0)