Skip to content

Commit d462675

Browse files
DOCSP-11298 doc for atleas search index create command (#163)
DOCSP-11298 fixes
1 parent 98ef5db commit d462675

File tree

5 files changed

+303
-1
lines changed

5 files changed

+303
-1
lines changed

conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
'data-lake': 'Atlas Data Lake',
7171
'data-lake-short': 'Data Lake',
7272
'data-lake-stores': 'data stores',
73-
'data-lake-store': 'data store'
73+
'data-lake-store': 'data store',
7474
}
7575

7676
rst_epilog = '\n'.join([
@@ -105,6 +105,7 @@
105105
'.. |epoch-time-ms| replace:: timestamp in the number of milliseconds that have elapsed since the `UNIX epoch <https://en.wikipedia.org/wiki/Unix_time?oldid=828172017>`__',
106106
'.. |Epoch-time| replace:: Timestamp in the number of seconds that have elapsed since the `UNIX epoch <https://en.wikipedia.org/wiki/Unix_time?oldid=828172017>`__',
107107
'.. |epoch-time| replace:: timestamp in the number of seconds that have elapsed since the `UNIX epoch <https://en.wikipedia.org/wiki/Unix_time?oldid=828172017>`__',
108+
'.. |fts| replace:: Atlas Search',
108109
'.. |fqdn| replace:: :abbr:`FQDN (fully qualified domain name)`',
109110
'.. |gcp| replace:: :abbr:`GCP (Google Cloud Platform)`',
110111
'.. |global-write-clusters| replace:: Global Clusters',
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
.. list-table::
2+
:widths: 20 10 70
3+
:header-rows: 1
4+
5+
* - Field
6+
- Type
7+
- Description
8+
9+
* - ``analyzer``
10+
- string
11+
- Name of the analyzer to use when creating the index. Value
12+
can be one of the following:
13+
14+
- :atlas:`lucene.standard </reference/atlas-search/analyzers/standard/>`
15+
- :atlas:`lucene.simple </reference/atlas-search/analyzers/simple/>`
16+
- :atlas:`lucene.whitespace
17+
</reference/atlas-search/analyzers/whitespace/>`
18+
- :atlas:`lucene.language </reference/atlas-search/analyzers/language/>`
19+
- :atlas:`lucene.keyword </reference/atlas-search/analyzers/keyword/>`
20+
21+
* - ``collectionName``
22+
- string
23+
- Name of the collection.
24+
25+
* - ``database``
26+
- string
27+
- Name of the database that contains the collection.
28+
29+
* - ``indexID``
30+
- string
31+
- Unique identifier of the |fts| index.
32+
33+
* - ``mappings``
34+
- document
35+
- Static or dynamic field mappings for the |fts| index.
36+
37+
* - ``mappings.dynamic``
38+
- string
39+
- Whether the |fts| index uses dynamic field mappings. Value can be
40+
one of the following:
41+
42+
- ``true`` if the ``dynamic`` flag is set, indicating dynamic field
43+
mappings.
44+
- ``false`` if the ``dynamic`` flag is not set, indicating static field
45+
mappings.
46+
47+
* - ``mappings.fields``
48+
- document or array of documents
49+
- List of indexed fields.
50+
51+
* - ``mappings.fields.[n].type``
52+
- string
53+
- Data type of the indexed field.
54+
55+
* - ``name``
56+
- string
57+
- Name of the index.
58+
59+
* - ``searchAnalyzer``
60+
- string
61+
- Name of the analyzer to use when searching the indexed field. Value
62+
can be one of the following:
63+
64+
- :atlas:`lucene.standard </reference/atlas-search/analyzers/standard/>`
65+
- :atlas:`lucene.simple </reference/atlas-search/analyzers/simple/>`
66+
- :atlas:`lucene.whitespace
67+
</reference/atlas-search/analyzers/whitespace/>`
68+
- :atlas:`lucene.language </reference/atlas-search/analyzers/language/>`
69+
- :atlas:`lucene.keyword </reference/atlas-search/analyzers/keyword/>`

source/reference/atlas/cluster-commands.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ Atlas ``cluster`` Commands
1717
Pause a Cluster </reference/atlas/cluster-pause>
1818
Resume a Cluster </reference/atlas/cluster-start>
1919
Watch a Cluster </reference/atlas/cluster-watch>
20+
Atlas Search </reference/atlas/search-commands>
2021
Online Archives </reference/atlas/onlinearchive-commands>
2122
Create a Rolling Index </reference/atlas/clusters-indexes-create>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.. _mcli-reference-atlas-search:
2+
3+
=====================
4+
Atlas Search Commands
5+
=====================
6+
7+
.. default-domain:: mongodb
8+
9+
.. toctree::
10+
:titlesonly:
11+
12+
Create an Atlas Search Index </reference/atlas/search-index-create>
13+
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
.. _mcli-atlas-search-index-create-command:
2+
3+
===========================================
4+
mongocli atlas cluster searach index create
5+
===========================================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
The ``search index create`` command creates an |fts| :atlas:`index
16+
</reference/atlas-search/index-definitions/>`. You can also create an
17+
|fts| :atlas:`index </reference/atlas-search/index-management/>` through
18+
the |service| :atlas:`UI </reference/atlas-search/create-index/>` or
19+
:atlas:`API </reference/api/fts-indexes-create-one/>`.
20+
21+
.. _mcli-atlas-search-index-create-syntax:
22+
23+
Syntax
24+
------
25+
26+
.. code-block:: text
27+
28+
mongocli atlas cluster search|fts index create <index-name>
29+
--clusterName <cluster-name>
30+
--collection <collection-name>
31+
--db <database-name>
32+
[ --dynamic ]
33+
[ --field <field-name>:<index-type> ]
34+
[ --profile|-P <profile-name> ]
35+
[ --projectId <project-ID> ]
36+
[ --searchAnalyzer <analyzer-name> ]
37+
38+
.. _mcli-atlas-search-index-create-options:
39+
40+
Options
41+
-------
42+
43+
.. list-table::
44+
:header-rows: 1
45+
:widths: 20 10 60 10
46+
47+
* - Option
48+
- Type
49+
- Description
50+
- Required?
51+
52+
* - ``<index-name>``
53+
- string
54+
- Name of the |fts| index.
55+
- yes
56+
57+
* - ``--clusterName``
58+
- string
59+
- Name of the cluster.
60+
- yes
61+
62+
* - ``--collection``
63+
- string
64+
- Name of the collection for which to create an |fts| index.
65+
- yes
66+
67+
* - ``--db``
68+
- string
69+
- Name of the database that contains the collection.
70+
- yes
71+
72+
* - ``--dynamic``
73+
- flag
74+
- Whether the |fts| index uses dynamic field mappings. This is
75+
required if ``field`` is not specified. You cannot specify
76+
``field`` if this flag is set.
77+
78+
To learn more, see :atlas:`Static and Dynamic Mappings
79+
<reference/atlas-search/index-definitions/#static-and-dynamic-mappings>`.
80+
- no
81+
82+
* - ``--field``
83+
- string
84+
- Comma-separated list of fields to index in the following format:
85+
86+
.. code-block:: text
87+
:copyable: false
88+
89+
<field-name>:<index-type>
90+
91+
where:
92+
93+
- ``<field-name>`` is the name of the field to index.
94+
- ``<index-type>`` is the :atlas:`type
95+
</reference/atlas-search/index-definitions/#data-types/>` of index.
96+
Value can be one of the following: ``autocomplete``, ``boolean``,
97+
``date``, ``document``, ``geo``, ``number``, ``objectId``, ``string``.
98+
99+
This is required if the index uses static mappings. You cannot set the
100+
``dynamic`` flag if field names are specified.
101+
- no
102+
103+
* - ``--profile``, ``-P``
104+
- string
105+
- Name of the profile where the public and private keys for the project
106+
are set. If omitted, uses the {+default-profile+}. To learn more about
107+
creating a profile, see :ref:`mcli-configure`.
108+
- no
109+
110+
* - ``--projectId``
111+
- string
112+
- Unique identifier of the project where you want to create the cluster.
113+
If omitted, uses the project ID in the profile or :ref:`environment
114+
variable <mcli-env-var>`.
115+
- no
116+
117+
* - ``--searchAnalyzer``
118+
- string
119+
- Analyzer to use when searching the index. Value can be one of the
120+
following:
121+
122+
- :atlas:`lucene.standard </reference/atlas-search/analyzers/standard/>`
123+
- :atlas:`lucene.simple </reference/atlas-search/analyzers/simple/>`
124+
- :atlas:`lucene.whitespace
125+
</reference/atlas-search/analyzers/whitespace/>`
126+
- :atlas:`lucene.language </reference/atlas-search/analyzers/language/>`
127+
- :atlas:`lucene.keyword </reference/atlas-search/analyzers/keyword/>`
128+
129+
If omitted, defaults to ``lucene.standard``.
130+
- no
131+
132+
.. _mcli-atlas-search-index-create-output:
133+
134+
Output
135+
------
136+
137+
.. include:: /includes/command-output-intro.rst
138+
139+
.. include:: /includes/atlas-search-index-output-fields.rst
140+
141+
.. _mcli-atlas-search-index-create-egs:
142+
143+
Examples
144+
--------
145+
146+
The following examples use the ``mongocli atlas cluster search index create``
147+
command to create an |fts| index named ``default`` on the
148+
``sample_mflix.movies`` collection in an |service| cluster named
149+
``myTestCluster``.
150+
151+
Create an Index for Dynamic Field Mappings
152+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153+
154+
The following ``mongocli atlas cluster search index create`` command creates
155+
an |fts| index that uses dynamic field mappings. It uses the ``egAtlasProfile``
156+
to access the project.
157+
158+
.. code-block:: text
159+
160+
mongocli atlas cluster search index create default --dynamic --clusterName myTestCluster --db sample_mflix --collection movies --profile egAtlasProfile
161+
162+
The previous command prints the following fields in |json| format to the
163+
terminal. To learn more about these fields, see
164+
:ref:`mcli-atlas-search-index-create-output`.
165+
166+
.. code-block:: json
167+
:copyable: false
168+
169+
{
170+
"analyzer": "lucene.standard",
171+
"collectionName": "movies",
172+
"database": "sample_mflix",
173+
"indexID": "5f1f40842f2ac35f49190c20",
174+
"mappings": {
175+
"dynamic": true
176+
},
177+
"name": "dynamic",
178+
"searchAnalyzer": "lucene.standard"
179+
}
180+
181+
Create an Index for Specific Fields
182+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183+
184+
The following ``mongocli atlas cluster search index create`` command creates
185+
an |fts| index that indexes the ``title`` field of type ``string`` using the
186+
``keyword`` analyzer and ``plot`` field of type ``string`` using the
187+
``keyword`` analyzer. It uses the {+default-profile+} to access the project.
188+
189+
.. code-block:: text
190+
191+
mongocli atlas cluster search index create default --clusterName myTestCluster --db sample_mflix --collection movies --field title:string,released:date
192+
193+
The previous command prints the following fields in |json| format to the
194+
terminal. To learn more about these fields, see
195+
:ref:`mcli-atlas-search-index-create-output`.
196+
197+
.. code-block:: json
198+
:copyable: false
199+
200+
{
201+
"analyzer": "lucene.standard",
202+
"collectionName": "movies",
203+
"database": "sample_mflix",
204+
"indexID": "5f2099cd683fc55fbb30bef6",
205+
"mappings": {
206+
"dynamic": false,
207+
"fields": {
208+
"released": {
209+
"type": "date"
210+
},
211+
"title": {
212+
"type": "string"
213+
}
214+
}
215+
},
216+
"name": "default",
217+
"searchAnalyzer": "lucene.standard"
218+
}

0 commit comments

Comments
 (0)