@@ -22,13 +22,13 @@ Overview
2222
2323In this guide, you can learn how to create MongoDB **indexes** by using your
2424Django models. Indexes can improve the efficiency of queries and add
25- additional functionality to querying and storing documents .
25+ additional query and document storage functionality .
2626
2727Without indexes, MongoDB must scan every document in a collection to find the
2828documents that match each query. These collection scans are
2929slow and can negatively affect the performance of your application. However, if an
3030appropriate index exists for a query, MongoDB can use the index to limit the
31- documents it must inspect .
31+ documents it inspects .
3232
3333Django provides the ``Index`` class, which you can use to create an
3434index on your model. {+django-odm+} creates the same index on your
@@ -47,7 +47,7 @@ The examples in this guide use the ``Recipe`` model, which contains an
4747embedded ``Nutrition`` model as the value of its ``nutrition`` field.
4848These model classes have the following definitions:
4949
50- .. literalinclude:: /includes/interact -data/specify-a-query .py
50+ .. literalinclude:: /includes/model -data/indexes .py
5151 :start-after: start-models
5252 :end-before: end-models
5353 :language: python
@@ -76,11 +76,11 @@ code:
7676 # add more indexes here
7777 ]
7878
79- To define your index, pass the following arguments to the ``Index()`` method:
79+ To define your index, pass the following arguments to the ``models. Index()`` method:
8080
8181- ``expressions``: Specifies a database expression to index. If you don't pass
8282 the ``fields`` argument, this argument is required. To learn more about this
83- argument, see the :ref:`django-indexes-expressions ` section of this guide.
83+ argument, see the :ref:`django-indexes-functions ` section of this guide.
8484
8585- ``fields``: Specifies a list of fields to index. If you don't pass the
8686 ``expressions`` argument, this argument is required.
@@ -189,8 +189,8 @@ an index on the ``nutrition`` embedded model field, which {+django-odm+} creates
189189on the ``recipes`` collection:
190190
191191.. literalinclude:: /includes/model-data/indexes.py
192- :start-after: start-multikey
193- :end-before: end-multikey
192+ :start-after: start-embedded
193+ :end-before: end-embedded
194194 :language: python
195195 :copyable:
196196 :emphasize-lines: 3-5
@@ -211,7 +211,7 @@ Partial Indexes
211211~~~~~~~~~~~~~~~
212212
213213Partial indexes index only the documents in a collection that meet specified
214- filter condition , which reduces storage use and performance costs.
214+ filter criteria , which reduces storage use and performance costs.
215215
216216To create a partial index, pass the ``condition`` argument to the ``models.Index()``
217217method. Set the condition value to a ``Q`` object that includes the filter
@@ -233,7 +233,7 @@ only index documents that have a ``cook_time`` value less than ``30``:
233233 :end-before: end-partial
234234 :language: python
235235 :copyable:
236- :emphasize-lines: 3-5
236+ :emphasize-lines: 3-7
237237
238238.. _django-indexes-unique:
239239
@@ -275,6 +275,7 @@ creates a unique compound index on these fields:
275275 :end-before: end-unique-compound
276276 :language: python
277277 :copyable:
278+ :emphasize-lines: 6-8
278279
279280.. tip::
280281
@@ -295,11 +296,11 @@ The following example updates the ``Recipe`` model's ``Meta`` class to create
295296an index on the sum of the ``cook_time`` and ``prep_time`` values:
296297
297298.. literalinclude:: /includes/model-data/indexes.py
298- :start-after: start-partial
299- :end-before: end-partial
299+ :start-after: start-expression
300+ :end-before: end-expression
300301 :language: python
301302 :copyable:
302- :emphasize-lines: 3-5
303+ :emphasize-lines: 3-7
303304
304305.. tip::
305306
@@ -315,7 +316,7 @@ To learn more about the index types mentioned in this guide,
315316see the following {+mdb-server+} manual resources:
316317
317318- :manual:`Single Field Indexes </core/index-single/>`
318- - :manual:`Compound Indexes </core/index-single />`
319+ - :manual:`Compound Indexes </core/index-compound />`
319320- :manual:`Multikey Indexes </core/index-multikey/>`
320321- :manual:`Embedded Document Indexes </core/index-single/create-embedded-object-index/>`
321322- :manual:`Partial Indexes </core/index-partial/>`
0 commit comments