1
1
.. _node-fundamentals-indexes:
2
2
.. _node-indexes:
3
3
4
- =======
5
- Indexes
6
- =======
4
+ ======================
5
+ Indexes on Collections
6
+ ======================
7
7
8
8
.. facet::
9
9
:name: genre
@@ -340,38 +340,38 @@ To learn more, see :manual:`Unique Indexes </core/index-unique>`.
340
340
341
341
.. _node-indexes-search:
342
342
343
- Search Indexes
344
- --------------
343
+ Atlas Search and Atlas Vector Search Indexes
344
+ --------------------------------------------
345
345
346
- Atlas Search is a feature that allows you to perform full-text
347
- searches. To learn more, see the :ref:`Atlas Search <fts-top-ref>`
348
- documentation.
346
+ You can programmatically manage your Atlas Search and Atlas Vector
347
+ Search indexes by using the {+driver-short+}.
349
348
350
- Before you can perform a search on an Atlas collection, you must first
351
- create an Atlas Search index on the collection. An Atlas Search
352
- index is a data structure that categorizes data in a searchable format.
349
+ The Atlas Search feature enables you to perform full-text searches on
350
+ collections hosted on MongoDB Atlas. To learn more about Atlas
351
+ Search, see the :atlas:`Atlas Search
352
+ </atlas-search/atlas-search-overview/>` documentation.
353
353
354
- You can use the following methods to manage your Search indexes:
354
+ Atlas Vector Search enables you to perform semantic searches on vector
355
+ embeddings stored in Atlas. To learn more about Atlas
356
+ Vector Search, see the :atlas:`Atlas Vector Search
357
+ </atlas-vector-search/vector-search-overview/>` documentation.
355
358
356
- - ``createSearchIndex()``
357
- - ``createSearchIndexes()``
358
- - ``listSearchIndexes()``
359
- - ``updateSearchIndex()``
360
- - ``dropSearchIndex()``
359
+ To learn more about how to run an Atlas Search or Atlas Vector Search query, see the
360
+ :ref:`node-atlas-search` or :ref:`node-atlas-vector-search` guide.
361
361
362
- The following sections provide code samples that use each of the preceding
363
- methods to manage Search indexes.
362
+ The following sections contain code examples that demonstrate how to manage Atlas
363
+ Search and Atlas Vector Search indexes.
364
364
365
365
Create a Search Index
366
366
~~~~~~~~~~~~~~~~~~~~~
367
367
368
368
You can use the `createSearchIndex()
369
369
<{+api+}/classes/Collection.html#createSearchIndex>`__ and
370
370
`createSearchIndexes() <{+api+}/classes/Collection.html#createSearchIndexes>`__
371
- methods to create new Search indexes.
371
+ methods to create new Atlas Search and Atlas Vector Search indexes.
372
372
373
373
The following code shows how to
374
- use the ``createSearchIndex()`` method to create an index called
374
+ use the ``createSearchIndex()`` method to create an Atlas Search index called
375
375
``search1``:
376
376
377
377
.. literalinclude:: /code-snippets/indexes/searchIndexes.js
@@ -380,15 +380,12 @@ use the ``createSearchIndex()`` method to create an index called
380
380
:start-after: start createSearchIndex example
381
381
:end-before: end createSearchIndex example
382
382
383
- When connecting to {+mdb-server+} v6.0.11 and later v6 versions, or
384
- v7.0.2 and later v7 versions, you can use the driver to create an Atlas
385
- Vector Search index on a collection. Learn more about this feature in
386
- the :atlas:`Atlas Vector Search documentation
387
- </atlas-vector-search/vector-search-overview/>`.
383
+ When connecting to {+mdb-server+} v6.0.11 and later, you can use the driver to
384
+ create an Atlas Vector Search index by specifying ``vectorSearch`` in the ``type``
385
+ field of the index definition.
388
386
389
387
The following code shows how to use the ``createSearchIndex()`` method
390
- to create a search index in which the ``type`` field is
391
- ``vectorSearch``:
388
+ to create an Atlas Vector Search index:
392
389
393
390
.. literalinclude:: /code-snippets/indexes/searchIndexes.js
394
391
:language: javascript
@@ -401,13 +398,14 @@ List Search Indexes
401
398
402
399
You can use the `listSearchIndexes()
403
400
<{+api+}/classes/Collection.html#listSearchIndexes>`__
404
- method to return a cursor that contains the Search indexes of a given
405
- collection. The ``listSearchIndexes()`` method takes an optional string
406
- parameter, ``name``, to return only the indexes with matching names. It
407
- also takes an optional `aggregateOptions <{+api+}/interfaces/AggregateOptions.html>`__ parameter.
401
+ method to return a cursor that contains the Atlas Search and Atlas Vector Search
402
+ indexes of a given collection. The ``listSearchIndexes()`` method takes an
403
+ optional string parameter, ``name``, to return only the indexes with matching
404
+ names. It also takes an optional
405
+ `aggregateOptions <{+api+}/interfaces/AggregateOptions.html>`__ parameter.
408
406
409
407
The following code uses the ``listSearchIndexes()`` method to list the
410
- Search indexes in a collection:
408
+ Atlas Search and Atlas Vector Search indexes in a collection:
411
409
412
410
.. literalinclude:: /code-snippets/indexes/searchIndexes.js
413
411
:language: javascript
@@ -419,12 +417,12 @@ Update a Search Index
419
417
~~~~~~~~~~~~~~~~~~~~~
420
418
421
419
You can use the `updateSearchIndex()
422
- <{+api+}/classes/Collection.html#updateSearchIndex>`__ method to update a Search
423
- index.
420
+ <{+api+}/classes/Collection.html#updateSearchIndex>`__ method to update an
421
+ Atlas Search or Atlas Vector Search index by providing a new index definition .
424
422
425
- The following code shows how to
426
- use the ``updateSearchIndex() `` method to update an index called
427
- ``search1 `` to specify a string type for the ``description`` field :
423
+ The following code shows how to use the ``updateSearchIndex()`` method to
424
+ update an Atlas Search index called ``search1 `` to change the type of the
425
+ ``description `` field to a string:
428
426
429
427
.. literalinclude:: /code-snippets/indexes/searchIndexes.js
430
428
:language: javascript
@@ -436,12 +434,11 @@ Drop a Search Index
436
434
~~~~~~~~~~~~~~~~~~~
437
435
438
436
You can use the `dropSearchIndex()
439
- <{+api+}/classes/Collection.html#dropSearchIndex>`__ method to remove a Search
440
- index.
437
+ <{+api+}/classes/Collection.html#dropSearchIndex>`__ method to remove an Atlas
438
+ Search or Atlas Vector Search index.
441
439
442
- The following code shows how to
443
- use the ``dropSearchIndex()`` method to remove an index called
444
- ``search1``:
440
+ The following code shows how to use the ``dropSearchIndex()`` method to remove
441
+ an index called ``search1``:
445
442
446
443
.. literalinclude:: /code-snippets/indexes/searchIndexes.js
447
444
:language: javascript
0 commit comments