@@ -118,7 +118,7 @@ following optional parameters to ``search()``:
118
118
- ``concurrent``: ``bool``
119
119
- ``count``: ``string``
120
120
- ``searchAfter``: ``string``
121
- - ``searchBefore`: ``string` ``
121
+ - ``searchBefore`` ``string``
122
122
- ``scoreDetails``: ``bool``
123
123
- ``sort``: ``array``
124
124
- ``returnStoredSource``: ``bool``
@@ -184,3 +184,79 @@ method to customize the query:
184
184
To learn more about these parameters, see the :atlas:`Options
185
185
</atlas-search/autocomplete/#options>` section of the
186
186
``autocomplete`` operator reference in the Atlas documentation.
187
+
188
+ Atlas Vector Search
189
+ -------------------
190
+
191
+ In this section, you can learn how to create Atlas Vector Search indexes
192
+ and perform searches in the {+odm-short+}. The Atlas Vector Search API
193
+ internally uses the ``$vectorSearch`` aggregation operator to perform queries.
194
+ To learn more about this operator, see the :atlas:`$vectorSearch
195
+ </atlas-vector-search/vector-search-stage/#mongodb-pipeline-pipe.-vectorSearch>`
196
+ reference in the Atlas documentation.
197
+
198
+ .. _laravel-avs-index:
199
+
200
+ Create an Atlas Vector Search Index
201
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
202
+
203
+ .. TODO in DOCSP-46230
204
+
205
+ Perform Queries
206
+ ~~~~~~~~~~~~~~~
207
+
208
+ In this section, you can learn how to use the Atlas Vector Search API in
209
+ the {+odm-short+}. The {+odm-short+} provides the ``vectorSearch()``
210
+ method as a query builder method and as an Eloquent model method. You
211
+ can use the ``vectorSearch()`` method to run Atlas Vector Search queries
212
+ on documents in your collections.
213
+
214
+ You must pass the following parameters to the ``search()`` method:
215
+
216
+ - ``index``: Name of the vector search index (type: ``string``)
217
+ - ``path``: Field that stores vector embeddings (type: ``array`` or ``string``)
218
+ - ``queryVector``: Vector representation of your query (type: ``array``)
219
+ - ``limit``: Number of results to return (type: ``int``)
220
+
221
+ The following code uses the index created in the preceding
222
+ :ref:`laravel-avs-index` section to perform an Atlas Vector Search query on the
223
+ ``movies`` collection:
224
+
225
+ .. io-code-block::
226
+ :copyable: true
227
+
228
+ .. input:: /includes/fundamentals/as-avs/AtlasSearchTest.php
229
+ :language: php
230
+ :dedent:
231
+ :start-after: start-vs-query
232
+ :end-before: end-vs-query
233
+
234
+ .. output::
235
+ :language: json
236
+ :visible: false
237
+
238
+ [
239
+ { "title": "Sunrising",
240
+ "plot": "A shy teenager discovers confidence and new friendships during a transformative summer camp experience."
241
+ },
242
+ { "title": "Last Semester",
243
+ "plot": "High school friends navigate love, identity, and unexpected challenges before graduating together."
244
+ }
245
+ ]
246
+
247
+ You can use the ``vector()`` method to perform many types of Atlas
248
+ Search queries. Depending on your desired query, you can pass the
249
+ following optional parameters to ``search()``:
250
+
251
+ - ``exact``: ``bool`` (default: ``false``)
252
+ - ``filter``: ``QueryInterface`` or ``array``
253
+ - ``numCandidates``: ``int`` or ``null`` (default: ``null``)
254
+
255
+ .. tip::
256
+
257
+ To construct a ``QueryInterface`` instance, you must import the
258
+ ``MongoDB\Builder\Query`` class into your application.
259
+
260
+ To learn more about these parameters, see the :atlas:`Fields
261
+ </atlas-vector-search/vector-search-stage/#fields>` section of the
262
+ ``$vectorSearch`` operator reference in the Atlas documentation.
0 commit comments