@@ -31,8 +31,8 @@ indexes:
31
31
:ref:`compound index <index-type-compound>`.
32
32
33
33
- Queries that are "covered" by the index return more quickly
34
- than queries that have to scan many individual documents. An index is
35
- considered to "cover " a query if all the data that the query must return
34
+ than queries that have to scan many individual documents. An index
35
+ "covers " a query if all the data that the query must return
36
36
is stored in within the keys of the index.
37
37
38
38
- Using queries with good index coverage will reduce the number of full
69
69
70
70
The ``_id`` index is a :ref:`unique index <index-type-unique>`
71
71
[#unique-index-report]_ on the ``_id`` field, and MongoDB creates this
72
- index by default on all collections. [#capped-collections]_ You cannot
72
+ index by default on all collections (except for [#capped-collections]). You cannot
73
73
delete the index on ``_id``.
74
74
75
75
The ``_id`` field is the :term:`primary key` for the collection, and
@@ -80,17 +80,20 @@ are 12-byte, unique identifiers, that make suitable ``_id`` values.
80
80
81
81
.. note::
82
82
83
- In :term:`shard clusters <shard cluster>`, if the you do *not* use
83
+ In :term:`shard clusters <shard cluster>`, if you do *not* use
84
84
the ``_id`` field as the :term:`shard key`, then your application
85
85
**must** ensure the uniqueness of the values in the ``_id`` field
86
- to prevent errors.
86
+ to prevent errors. This is most-often done by using the standard
87
+ auto-generated :term:`ObjectIds`.
87
88
88
89
.. [#unique-index-report] Although the index on ``_id`` *is* unique,
89
90
the :func:`getIndexes() <db.collection.getIndexes()>` method will
90
91
*not* print ``unique: true`` in the :program:`mongo` shell.
91
92
92
- .. [#capped-collections] Capped collections are a special collection
93
- which do not have an ``_id`` index.
93
+ .. [#capped-collections] Capped collections are special collections
94
+ which do not have an ``_id`` index by default.
95
+ TODO: figure out what new behavior of capped collections is.
96
+ (i think in replset capped collections now have _id by default)
94
97
95
98
.. _index-types-secondary:
96
99
@@ -109,9 +112,9 @@ primary, common, and user-facing queries and require MongoDB to scan
109
112
the fewest number of documents possible.
110
113
111
114
To create a secondary index, use the :func:`ensureIndex()`
112
- method. The specifications an index using the :func:`ensureIndex()
113
- <db.collection.ensureIndex()>` operation will resemble the following
114
- on the MongoDB shell:
115
+ method. The argument to :func:`ensureIndex()
116
+ <db.collection.ensureIndex()>` will resemble the following
117
+ in the MongoDB shell:
115
118
116
119
.. code-block:: javascript
117
120
@@ -142,7 +145,7 @@ documents that resemble the following example document:
142
145
}
143
146
}
144
147
145
- You could create an index on the ``address.zipcode`` field, using the
148
+ You can create an index on the ``address.zipcode`` field, using the
146
149
following specification:
147
150
148
151
.. code-block:: javascript
@@ -160,7 +163,7 @@ Compound Indexes
160
163
MongoDB supports "compound indexes," where a single index structure
161
164
holds references to multiple fields within a collection's
162
165
documents. Consider the collection ``products`` that holds documents
163
- that resemble the following an example document:
166
+ that resemble the following example document:
164
167
165
168
.. code-block:: javascript
166
169
0 commit comments