@@ -61,6 +61,25 @@ appropriate for your application, see the MongoDB server documentation on
61
61
:manual:`Indexing Strategies </applications/indexes>` and
62
62
:manual:`Data Modeling and Indexes </core/data-model-operations/#data-model-indexes>`.
63
63
64
+ List Indexes
65
+ ~~~~~~~~~~~~
66
+
67
+ You can use the ``listIndexes()`` method to list all of the indexes
68
+ for a collection. The `listIndexes() <{+api+}/classes/Collection.html#listIndexes>`__ method takes an
69
+ optional `ListIndexesOptions
70
+ <{+api+}/interfaces/ListIndexesOptions.html>`__ parameter. The ``listIndexes()`` method returns an
71
+ object of type `ListIndexesCursor
72
+ <{+api+}/classes/ListIndexesCursor.html>`__.
73
+
74
+ The following code uses the ``listIndexes()`` method to list all the
75
+ indexes in a collection:
76
+
77
+ .. literalinclude:: /code-snippets/indexes/listIndexes.js
78
+ :language: javascript
79
+ :dedent:
80
+ :start-after: start listIndexes example
81
+ :end-before: end listIndexes example
82
+
64
83
Index Types
65
84
-----------
66
85
@@ -313,42 +332,97 @@ the following:
313
332
314
333
To learn more, see :manual:`Unique Indexes </core/index-unique>`.
315
334
316
- List Indexes
317
- ------------
335
+ .. _node-indexes-search:
318
336
319
- You can use the ``listIndexes()`` method to list all of the indexes
320
- for a collection. The `listIndexes() <{+api+}/classes/Collection.html#listIndexes>`__ method takes an
321
- optional `ListIndexesOptions
322
- <{+api+}/interfaces/ListIndexesOptions.html>`__ parameter. The ``listIndexes()`` method returns an
323
- object of type `ListIndexesCursor
324
- <{+api+}/classes/ListIndexesCursor.html>`__.
337
+ Search Indexes
338
+ --------------
325
339
326
- The following code uses the ``listIndexes()`` method to list all the
327
- indexes in a collection:
340
+ Atlas Search is a feature that allows you to perform full-text
341
+ searches. To learn more, see the :ref:`Atlas Search <fts-top-ref>`
342
+ documentation.
328
343
329
- .. literalinclude:: /code-snippets/indexes/listIndexes.js
344
+ Before you can perform a search on an Atlas collection, you must first
345
+ create an Atlas Search index on the collection. An Atlas Search
346
+ index is a data structure that categorizes data in a searchable format.
347
+
348
+ You can use the following methods to manage your Search indexes:
349
+
350
+ - ``createSearchIndex()``
351
+ - ``createSearchIndexes()``
352
+ - ``listSearchIndexes()``
353
+ - ``updateSearchIndex()``
354
+ - ``dropSearchIndex()``
355
+
356
+ The following sections provide code samples that use each of the preceding
357
+ methods to manage Search indexes.
358
+
359
+ Create a Search Index
360
+ ~~~~~~~~~~~~~~~~~~~~~
361
+
362
+ You can use the `createSearchIndex()
363
+ <{+api+}/classes/Collection.html#createSearchIndex>`__ and
364
+ `createSearchIndexes() <{+api+}/classes/Collection.html#createSearchIndexes>`__
365
+ methods to create new Search indexes.
366
+
367
+ The following code shows how to
368
+ use the ``createSearchIndex()`` method to create an index called
369
+ ``search1``:
370
+
371
+ .. literalinclude:: /code-snippets/indexes/searchIndexes.js
330
372
:language: javascript
331
373
:dedent:
332
- :start-after: start listIndexes example
333
- :end-before: end listIndexes example
374
+ :start-after: start createSearchIndex example
375
+ :end-before: end createSearchIndex example
334
376
335
377
List Search Indexes
336
378
~~~~~~~~~~~~~~~~~~~
337
379
338
- When connecting to {+mdb-server+} version 7.0 or later, you can use the new `listSearchIndexes()
339
- <https://mongodb.github.io/node-mongodb-native/Next/classes/Collection.html#listSearchIndexes>`__
340
- method to return a cursor that contains the search indexes of a given
341
- collection. The ``listSearchIndexes()`` method takes an optional string parameter, ``name``, to
342
- return only the indexes with matching index names. It also takes an
343
- optional `aggregateOptions
344
- <https://mongodb.github.io/node-mongodb-native/Next/interfaces/AggregateOptions.html>`__
345
- parameter.
380
+ You can use the `listSearchIndexes()
381
+ <{+api+}/classes/Collection.html#listSearchIndexes>`__
382
+ method to return a cursor that contains the Search indexes of a given
383
+ collection. The ``listSearchIndexes()`` method takes an optional string
384
+ parameter, ``name``, to return only the indexes with matching names. It
385
+ also takes an optional `aggregateOptions <{+api+}/interfaces/AggregateOptions.html>`__ parameter.
346
386
347
- The following code uses the ``listSearchIndexes()`` method to list all
348
- the search indexes in the collection:
387
+ The following code uses the ``listSearchIndexes()`` method to list the
388
+ Search indexes in a collection:
349
389
350
- .. literalinclude:: /code-snippets/indexes/listSearchIndexes .js
390
+ .. literalinclude:: /code-snippets/indexes/searchIndexes .js
351
391
:language: javascript
352
392
:dedent:
353
393
:start-after: start listSearchIndexes example
354
- :end-before: end listSearchIndexes example
394
+ :end-before: end listSearchIndexes example
395
+
396
+ Update a Search Index
397
+ ~~~~~~~~~~~~~~~~~~~~~
398
+
399
+ You can use the `updateSearchIndex()
400
+ <{+api+}/classes/Collection.html#updateSearchIndex>`__ method to update a Search
401
+ index.
402
+
403
+ The following code shows how to
404
+ use the ``updateSearchIndex()`` method to update an index called
405
+ ``search1`` to specify a string type for the ``description`` field:
406
+
407
+ .. literalinclude:: /code-snippets/indexes/searchIndexes.js
408
+ :language: javascript
409
+ :dedent:
410
+ :start-after: start updateSearchIndex example
411
+ :end-before: end updateSearchIndex example
412
+
413
+ Drop a Search Index
414
+ ~~~~~~~~~~~~~~~~~~~
415
+
416
+ You can use the `dropSearchIndex()
417
+ <{+api+}/classes/Collection.html#dropSearchIndex>`__ method to remove a Search
418
+ index.
419
+
420
+ The following code shows how to
421
+ use the ``dropSearchIndex()`` method to remove an index called
422
+ ``search1``:
423
+
424
+ .. literalinclude:: /code-snippets/indexes/searchIndexes.js
425
+ :language: javascript
426
+ :dedent:
427
+ :start-after: start dropSearchIndex example
428
+ :end-before: end dropSearchIndex example
0 commit comments