Skip to content

Commit 7fabc7d

Browse files
(DOCSP-34890): Add vector search index type for Atlas Search management commands (#5747) (#6328)
* WIP * (DOCSP-34890): Add vector search index type for Atlas Search management commands * fix pluralization * add taxonomy info * tweak vector syntax * add Learn More section * formatting fix * fix formatting * remove comma * fix code block formatting * address review feedback * consistent wording * remove word * tweak example explanation
1 parent 3c7422f commit 7fabc7d

File tree

4 files changed

+144
-7
lines changed

4 files changed

+144
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Type of search index to create. You can specify either:
2+
3+
- ``search``
4+
- ``vectorSearch``
5+
6+
If you omit the ``type`` field, the index type is ``search``.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
The vector search index definition takes the following fields:
2+
3+
.. code-block:: javascript
4+
5+
{
6+
"fields": [
7+
{
8+
"type": "vector" | "filter",
9+
"path": "<field-to-index>",
10+
"numDimensions": <number-of-dimensions>,
11+
"similarity": "euclidean" | "cosine" | "dotProduct"
12+
}
13+
]
14+
}
15+
16+
For explanations of vector search index definition fields, see
17+
:ref:`avs-types-vector-search`.

source/reference/command/createSearchIndexes.txt

+63-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ createSearchIndexes
44

55
.. default-domain:: mongodb
66

7+
.. meta::
8+
:keywords: atlas search
9+
710
.. contents:: On this page
811
:local:
912
:backlinks: none
@@ -17,7 +20,7 @@ Definition
1720

1821
.. versionadded:: 7.0 (*Also available starting in 6.0.7*)
1922

20-
.. |fts-indexes| replace:: :atlas:`{+fts+} indexes </atlas-search/atlas-search-overview/#fts-indexes>`
23+
.. |fts-indexes| replace:: :atlas:`{+fts+} indexes </atlas-search/atlas-search-overview/#fts-indexes>` or :atlas:`Vector Search indexes </atlas-vector-search/vector-search-overview/>`
2124

2225
.. include:: /includes/atlas-search-commands/command-descriptions/createSearchIndexes-description.rst
2326

@@ -39,6 +42,7 @@ Command syntax:
3942
indexes: [
4043
{
4144
name: "<index name>",
45+
type: "<search index type>",
4246
definition: {
4347
/* search index definition fields */
4448
}
@@ -82,11 +86,20 @@ The ``createSearchIndexes`` command takes the following fields:
8286

8387
If you do not specify a ``name``, the index is named ``default``.
8488

89+
* - ``indexes.type``
90+
- string
91+
- Optional
92+
- .. include:: /includes/atlas-search-commands/field-definitions/type.rst
93+
8594
* - ``indexes.definition``
8695
- document
8796
- Required
88-
- Document describing the index to create. For details on
89-
``definition`` syntax, see :ref:`search-index-definition-create`.
97+
- Document describing the index to create. The ``definition`` syntax
98+
depends on whether you create a standard search index or a Vector
99+
Search index. For the ``definition`` syntax, see:
100+
101+
- :ref:`search-index-definition-create`
102+
- :ref:`vector-search-index-definition-create`
90103

91104
.. _search-index-definition-create:
92105

@@ -95,6 +108,13 @@ Search Index Definition Syntax
95108

96109
.. include:: /includes/atlas-search-commands/search-index-definition-fields.rst
97110

111+
.. _vector-search-index-definition-create:
112+
113+
Vector Search Index Definition Syntax
114+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115+
116+
.. include:: /includes/atlas-search-commands/vector-search-index-definition-fields.rst
117+
98118
Behavior
99119
--------
100120

@@ -241,3 +261,43 @@ or digits.
241261
``searchIndex03`` uses a dynamic field mapping, meaning the index
242262
contains all fields in the collection that have :ref:`supported data
243263
types <bson-data-chart>`.
264+
265+
Create a Vector Search Index
266+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
267+
268+
The following example creates a vector search index named
269+
``vectorSearchIndex01`` on the ``movies`` collection:
270+
271+
.. code-block:: javascript
272+
273+
db.runCommand( {
274+
createSearchIndexes: "movies",
275+
indexes: [
276+
{
277+
name: "vectorSearchIndex01",
278+
type: "vectorSearch",
279+
definition: {
280+
fields: [
281+
{
282+
type: "vector",
283+
numDimensions: 1,
284+
path: "genre",
285+
similarity: "cosine"
286+
}
287+
]
288+
}
289+
}
290+
]
291+
} )
292+
293+
The vector search index contains one dimension and indexes the
294+
``genre`` field.
295+
296+
Learn More
297+
----------
298+
299+
- :pipeline:`$vectorSearch` aggregation stage
300+
301+
- :ref:`Tutorial: Semantic Search <vector-search--tutorial>`
302+
303+
- :atlas:`Atlas Vector Search Changelog </atlas-vector-search/changelog/>`

source/reference/method/db.collection.createSearchIndex.txt

+58-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ db.collection.createSearchIndex()
44

55
.. default-domain:: mongodb
66

7+
.. meta::
8+
:keywords: atlas search
9+
710
.. contents:: On this page
811
:local:
912
:backlinks: none
@@ -17,7 +20,7 @@ Definition
1720

1821
.. versionadded:: 7.0 (*Also available starting in 6.0.7*)
1922

20-
.. |fts-index| replace:: :atlas:`{+fts+} index </atlas-search/atlas-search-overview/#fts-indexes>`
23+
.. |fts-index| replace:: :atlas:`{+fts+} index </atlas-search/atlas-search-overview/#fts-indexes>` or :atlas:`Vector Search index </atlas-vector-search/vector-search-overview/>`
2124

2225
.. include:: /includes/atlas-search-commands/command-descriptions/createSearchIndex-method.rst
2326

@@ -36,6 +39,7 @@ Command syntax:
3639

3740
db.<collection>.createSearchIndex(
3841
<name>,
42+
<type>,
3943
{
4044
<definition>
4145
}
@@ -65,12 +69,20 @@ Command Fields
6569

6670
If you do not specify a ``name``, the index is named ``default``.
6771

72+
* - ``type``
73+
- string
74+
- Optional
75+
- .. include:: /includes/atlas-search-commands/field-definitions/type.rst
76+
6877
* - ``definition``
6978
- document
7079
- Required
71-
- Document describing the index to create. For details on
72-
``definition`` syntax, see
73-
:ref:`search-index-definition-create-mongosh`.
80+
- Document describing the index to create. The ``definition`` syntax
81+
depends on whether you create a standard search index or a Vector
82+
Search index. For the ``definition`` syntax, see:
83+
84+
- :ref:`search-index-definition-create-mongosh`
85+
- :ref:`vector-search-index-definition-create-mongosh`
7486

7587
.. _search-index-definition-create-mongosh:
7688

@@ -79,6 +91,13 @@ Search Index Definition Syntax
7991

8092
.. include:: /includes/atlas-search-commands/search-index-definition-fields.rst
8193

94+
.. _vector-search-index-definition-create-mongosh:
95+
96+
Vector Search Index Definition Syntax
97+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98+
99+
.. include:: /includes/atlas-search-commands/vector-search-index-definition-fields.rst
100+
82101
Behavior
83102
--------
84103

@@ -166,3 +185,38 @@ with the name ``default`` on the ``food`` collection:
166185
}
167186
}
168187
)
188+
189+
Create a Vector Search Index
190+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191+
192+
The following example creates a vector search index named
193+
``vectorSearchIndex01`` on the ``movies`` collection:
194+
195+
.. code-block:: javascript
196+
197+
db.movies.createSearchIndex(
198+
"vectorSearchIndex01",
199+
"vectorSearch",
200+
{
201+
fields: [
202+
{
203+
type: "vector",
204+
numDimensions: 1,
205+
path: "genre",
206+
similarity: "cosine"
207+
}
208+
]
209+
}
210+
)
211+
212+
The vector search index contains one dimension and indexes the ``genre``
213+
field.
214+
215+
Learn More
216+
----------
217+
218+
- :pipeline:`$vectorSearch` aggregation stage
219+
220+
- :ref:`Tutorial: Semantic Search <vector-search--tutorial>`
221+
222+
- :atlas:`Atlas Vector Search Changelog </atlas-vector-search/changelog/>`

0 commit comments

Comments
 (0)