@@ -5,17 +5,17 @@ Atlas Vector Search
55===================
66
77.. facet::
8- :name: genre
9- :values: reference
8+ :name: genre
9+ :values: reference
1010
1111.. meta::
12- :keywords: code example, semantic, text, embeddings
12+ :keywords: code example, semantic, text, embeddings
1313
1414.. contents:: On this page
15- :local:
16- :backlinks: none
17- :depth: 2
18- :class: singlecol
15+ :local:
16+ :backlinks: none
17+ :depth: 2
18+ :class: singlecol
1919
2020Overview
2121--------
@@ -28,9 +28,9 @@ perform Atlas Vector Search queries by using the :ref:`Aggregation Builder API
2828
2929.. note:: Deployment Compatibility
3030
31- You can use the Atlas Search feature only when
32- you connect to MongoDB Atlas clusters. This feature is not
33- available for self-managed deployments.
31+ You can use the Atlas Search feature only when
32+ you connect to MongoDB Atlas clusters. This feature is not
33+ available for self-managed deployments.
3434
3535To learn more about Atlas Vector Search, see the :atlas:`Overview
3636</atlas-vector-search/vector-search-overview/>` in the
@@ -43,15 +43,15 @@ Atlas documentation.
4343
4444.. note::
4545
46- You might not be able to use the methods described in
47- this guide for every type of Atlas Search query. For more complex use
48- cases, you can follow the standard way to create aggregation
49- pipelines in the {+library-short+}. To learn more, see the
50- :ref:`php-aggregation` guide.
46+ You might not be able to use the methods described in
47+ this guide for every type of Atlas Search query. For more complex use
48+ cases, you can follow the standard way to create aggregation
49+ pipelines in the {+library-short+}. To learn more, see the
50+ :ref:`php-aggregation` guide.
5151
52- To perform advanced full-text search on your documents, you can use the
53- Atlas Search API. To learn about this feature, see the
54- :ref:`php-atlas-search` guide.
52+ To perform advanced full-text search on your documents, you can use the
53+ Atlas Search API. To learn about this feature, see the
54+ :ref:`php-atlas-search` guide.
5555
5656Atlas Vector Search Index
5757~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -68,59 +68,59 @@ Search queries by using the Aggregation Builder:
6868
6969.. code-block:: php
7070
71- use MongoDB\Builder\Pipeline;
72- use MongoDB\Builder\Query;
73- use MongoDB\Builder\Stage;
71+ use MongoDB\Builder\Pipeline;
72+ use MongoDB\Builder\Query;
73+ use MongoDB\Builder\Stage;
7474
7575To create a ``$search`` stage in your aggregation pipeline, you must
7676perform the following actions:
7777
78781. Create a ``Pipeline`` class instance to create the pipeline
7979
8080#. Within the ``Pipeline`` instance, call the ``Stage::vectorSearch()`` method
81- to create the Atlas Vector Search stage
81+ to create the Atlas Vector Search stage
8282
8383#. Within the body of the ``vectorSearch()`` method, specify the
84- criteria for your vector query
84+ criteria for your vector query
8585
8686The following code demonstrates the template for constructing basic Atlas Search
8787queries:
8888
8989.. code-block:: php
9090
91- $pipeline = new Pipeline(
92- Stage::vectorSearch(
93- // Atlas Vector Search query specifications
94- // index: '<index name>',
95- // path: '<path to embeddings>',
96- // ...
97- ),
98- );
91+ $pipeline = new Pipeline(
92+ Stage::vectorSearch(
93+ // Atlas Vector Search query specifications
94+ // index: '<index name>',
95+ // path: '<path to embeddings>',
96+ // ...
97+ ),
98+ );
9999
100100You must pass the following parameters to the ``vectorSearch()`` method:
101101
102102.. list-table::
103- :header-rows: 1
103+ :header-rows: 1
104104
105- * - Parameter
106- - Type
107- - Description
105+ * - Parameter
106+ - Type
107+ - Description
108108
109- * - ``index``
110- - ``string``
111- - Name of the vector search index
109+ * - ``index``
110+ - ``string``
111+ - Name of the vector search index
112112
113- * - ``path``
114- - ``array`` or ``string``
115- - Field that stores vector embeddings
113+ * - ``path``
114+ - ``array`` or ``string``
115+ - Field that stores vector embeddings
116116
117- * - ``queryVector``
118- - ``array``
119- - Vector representation of your query
117+ * - ``queryVector``
118+ - ``array``
119+ - Vector representation of your query
120120
121- * - ``limit``
122- - ``int``
123- - Number of results to return
121+ * - ``limit``
122+ - ``int``
123+ - Number of results to return
124124
125125Atlas Search Query Examples
126126---------------------------
@@ -137,22 +137,22 @@ The following code performs an Atlas Vector Search query on the
137137``plot_embedding`` vector field:
138138
139139.. io-code-block::
140- :copyable: true
140+ :copyable: true
141141
142- .. input:: /includes/aggregation/vector-search.php
143- :language: php
144- :dedent:
145- :start-after: start-basic-query
146- :end-before: end-basic-query
142+ .. input:: /includes/aggregation/vector-search.php
143+ :language: php
144+ :dedent:
145+ :start-after: start-basic-query
146+ :end-before: end-basic-query
147147
148- .. output::
149- :language: json
150- :visible: false
148+ .. output::
149+ :language: json
150+ :visible: false
151151
152- {"_id": ...,"title":"About Time",...}
153- {"_id": ...,"title":"Tomorrowland",...}
154- {"_id": ...,"title":"Timecop",...}
155- // Results truncated
152+ {"_id": ...,"title":"About Time",...}
153+ {"_id": ...,"title":"Tomorrowland",...}
154+ {"_id": ...,"title":"Timecop",...}
155+ // Results truncated
156156
157157Vector Search Score
158158~~~~~~~~~~~~~~~~~~~
@@ -162,22 +162,22 @@ but outputs only the ``title`` field and ``vectorSearchScore`` meta
162162field, which describes how well the document matches the query vector:
163163
164164.. io-code-block::
165- :copyable: true
165+ :copyable: true
166166
167- .. input:: /includes/aggregation/vector-search.php
168- :language: php
169- :dedent:
170- :start-after: start-score-query
171- :end-before: end-score-query
167+ .. input:: /includes/aggregation/vector-search.php
168+ :language: php
169+ :dedent:
170+ :start-after: start-score-query
171+ :end-before: end-score-query
172172
173- .. output::
174- :language: json
175- :visible: false
173+ .. output::
174+ :language: json
175+ :visible: false
176176
177- {"title":"About Time","score":0.7843604683876038}
178- {"title":"Timecop","score":0.7771612405776978}
179- {"title":"Tomorrowland","score":0.7669923901557922}
180- // Results truncated
177+ {"title":"About Time","score":0.7843604683876038}
178+ {"title":"Timecop","score":0.7771612405776978}
179+ {"title":"Tomorrowland","score":0.7669923901557922}
180+ // Results truncated
181181
182182Vector Search Options
183183~~~~~~~~~~~~~~~~~~~~~
@@ -187,29 +187,29 @@ Vector Search queries. Depending on your desired query, you can pass the
187187following optional parameters to ``vectorSearch()``:
188188
189189.. list-table::
190- :header-rows: 1
191-
192- * - Optional Parameter
193- - Type
194- - Description
195- - Default Value
196-
197- * - ``exact``
198- - ``bool``
199- - Specifies whether to run an Exact Nearest Neighbor (``true``) or
200- Approximate Nearest Neighbor (``false``) search
201- - ``false``
202-
203- * - ``filter``
204- - ``QueryInterface`` or ``array``
205- - Specifies a pre-filter for documents to search on
206- - no filtering
207-
208- * - ``numCandidates``
209- - ``int`` or ``null``
210- - Specifies the number of nearest neighbors to use during the
211- search
212- - ``null``
190+ :header-rows: 1
191+
192+ * - Optional Parameter
193+ - Type
194+ - Description
195+ - Default Value
196+
197+ * - ``exact``
198+ - ``bool``
199+ - Specifies whether to run an Exact Nearest Neighbor (``true``) or
200+ Approximate Nearest Neighbor (``false``) search
201+ - ``false``
202+
203+ * - ``filter``
204+ - ``QueryInterface`` or ``array``
205+ - Specifies a pre-filter for documents to search on
206+ - no filtering
207+
208+ * - ``numCandidates``
209+ - ``int`` or ``null``
210+ - Specifies the number of nearest neighbors to use during the
211+ search
212+ - ``null``
213213
214214To learn more about these parameters, see the :atlas:`Fields
215215</atlas-vector-search/vector-search-stage/#fields>` section of the
0 commit comments