@@ -65,6 +65,17 @@ resulting index.
65
65
only creates an index if an index of the same specification does
66
66
not already exist.
67
67
68
+ Special Creation Options
69
+ ~~~~~~~~~~~~~~~~~~~~~~~~
70
+
71
+ .. note::
72
+
73
+ TTL collections use a special ``expire`` index option. See
74
+ :doc:`/tutorial/expire-data` for more information.
75
+
76
+ .. TODO: insert link here to the geospatial index documents when
77
+ they're published.
78
+
68
79
Sparse Indexes
69
80
``````````````
70
81
@@ -135,6 +146,46 @@ You can also enforce a unique constraint on :ref:`compound indexes
135
146
These indexes enforce uniqueness for the *combination* of index keys
136
147
and *not* for either key individually.
137
148
149
+ Background
150
+ ``````````
151
+
152
+ To create an index in the background you can specify :ref:`background
153
+ construction <index-creation-background>`. Consider the following
154
+ prototype invocation of :method:`db.collection.ensureIndex()`:
155
+
156
+ .. code-block:: javascript
157
+
158
+ db.collection.ensureIndex( { a: 1 }, { background: true } )
159
+
160
+ Consider the section on :ref:`background index construction
161
+ <index-creation-background>` for more information about these indexes
162
+ and their implications.
163
+
164
+ Drop Duplicates
165
+ ```````````````
166
+
167
+ To force the creation of a :ref:`unique index <index-type-unique>`
168
+ index on a collection with duplicate values in the field you are
169
+ indexing you can use the ``dropDups`` option. This will force MongoDB
170
+ to create a *unique* index by deleting documents with duplicate values
171
+ when building the index. Consider the following prototype invocation
172
+ of :method:`db.collection.ensureIndex()`:
173
+
174
+ .. code-block:: javascript
175
+
176
+ db.collection.ensureIndex( { a: 1 }, { dropDups: true } )
177
+
178
+ See the full documentation of :ref:`duplicate dropping
179
+ <index-creation-duplicate-dropping>` for more information.
180
+
181
+ .. warning::
182
+
183
+ Specifying ``{ dropDups: true }`` may delete data from your
184
+ database. Use with extreme caution.
185
+
186
+ Refer to the :method:`ensureIndex() <db.collection.ensureIndex()>`
187
+ documentation for additional index creation options.
188
+
138
189
Removal
139
190
~~~~~~~
140
191
@@ -159,7 +210,7 @@ Where the value of ``nIndexesWas`` reflects the number of indexes
159
210
for the :ref:`_id index <index-type-primary>` from a collection.
160
211
161
212
These shell helpers provide wrappers around the
162
- :dbcommand:`deleteIndexes ` :term:`database command`. Your :doc:`client
213
+ :dbcommand:`dropIndexes ` :term:`database command`. Your :doc:`client
163
214
library </applications/drivers>` may have a different or additional
164
215
interface for these operations.
165
216
@@ -203,54 +254,6 @@ may have a different or additional interface for this operation.
203
254
204
255
.. include:: /includes/note-build-indexes-on-replica-sets.rst
205
256
206
- Special Creation Options
207
- ~~~~~~~~~~~~~~~~~~~~~~~~
208
-
209
- .. note::
210
-
211
- TTL collections use a special ``expire`` index option. See
212
- :doc:`/tutorial/expire-data` for more information.
213
-
214
- .. TODO: insert link here to the geospatial index documents when
215
- they're published.
216
-
217
- Background
218
- ``````````
219
-
220
- To create an index in the background you can specify :ref:`background
221
- construction <index-creation-background>`. Consider the following
222
- prototype invocation of :method:`db.collection.ensureIndex()`:
223
-
224
- .. code-block:: javascript
225
-
226
- db.collection.ensureIndex( { a: 1 }, { background: true } )
227
-
228
- Consider the section on :ref:`background index construction
229
- <index-creation-background>` for more information about these indexes
230
- and their implications.
231
-
232
- Drop Duplicates
233
- ```````````````
234
-
235
- To force the creation of a :ref:`unique index <index-type-unique>`
236
- index on a collection with duplicate values in the field you are
237
- indexing you can use the ``dropDups`` option. This will force MongoDB
238
- to create a *unique* index by deleting documents with duplicate values
239
- when building the index. Consider the following prototype invocation
240
- of :method:`db.collection.ensureIndex()`:
241
-
242
- .. code-block:: javascript
243
-
244
- db.collection.ensureIndex( { a: 1 }, { dropDups: true } )
245
-
246
- See the full documentation of :ref:`duplicate dropping
247
- <index-creation-duplicate-dropping>` for more information.
248
-
249
- .. warning::
250
-
251
- Specifying ``{ dropDups: true }`` may delete data from your
252
- database. Use with extreme caution.
253
-
254
257
.. _index-building-replica-sets:
255
258
256
259
Building Indexes on Replica Sets
0 commit comments