@@ -21,12 +21,12 @@ Overview
2121--------
2222
2323In this guide, you can learn how to create MongoDB **indexes** by using your
24- Django models. Indexes can improve the efficiency of queries and add
24+ Django models. Indexes can improve the efficiency of queries and provide
2525additional query and document storage functionality.
2626
2727Without indexes, MongoDB must scan every document in a collection to find the
28- documents that match each query. These collection scans are
29- slow and can negatively affect the performance of your application. However, if an
28+ documents that match a query. These collection scans are slow and can
29+ negatively affect the performance of your application. However, if an
3030appropriate index exists for a query, MongoDB can use the index to limit the
3131documents it inspects.
3232
@@ -53,10 +53,11 @@ These model classes have the following definitions:
5353 :language: python
5454 :copyable:
5555
56- The ``db_table = "recipes"`` option instructs {+django-odm+} to map the ``Recipe``
57- model to a MongoDB collection called ``recipes``. To learn how to
58- create a Django application that uses models to interact with MongoDB
59- collections, visit the :ref:`django-get-started` tutorial.
56+ In the ``Recipe`` model's ``Meta`` class, the ``db_table = "recipes"`` option
57+ instructs {+django-odm+} to map the ``Recipe`` model to a MongoDB collection
58+ called ``recipes``. To learn how to create a Django application that
59+ uses models to interact with MongoDB collections, visit the
60+ :ref:`django-get-started` tutorial.
6061
6162Create an Index
6263---------------
@@ -80,7 +81,7 @@ To define your index, pass the following arguments to the ``models.Index()`` met
8081
8182- ``expressions``: Specifies a database expression to index. If you don't pass
8283 the ``fields`` argument, this argument is required. To learn more about this
83- argument, see the :ref:`django-indexes-functions ` section of this guide.
84+ argument, see the :ref:`django-indexes-expressions ` section of this guide.
8485
8586- ``fields``: Specifies a list of fields to index. If you don't pass the
8687 ``expressions`` argument, this argument is required.
@@ -203,7 +204,7 @@ index types:
203204
204205- :ref:`django-indexes-partial`
205206- :ref:`django-indexes-unique`
206- - :ref:`django-indexes-functions `
207+ - :ref:`django-indexes-expressions `
207208
208209.. _django-indexes-partial:
209210
@@ -266,7 +267,7 @@ Compound Example
266267````````````````
267268
268269The following example updates the ``Recipe`` model's ``Meta`` class to create
269- a compound index on the ``title`` and ``cuisine`` fields. Then, the code
270+ a compound index on the ``title`` and ``cuisine`` fields. The code
270271sets the ``constraints`` option to a ``UniqueConstraint`` instance, which
271272creates a unique compound index on these fields:
272273
@@ -275,17 +276,19 @@ creates a unique compound index on these fields:
275276 :end-before: end-unique-compound
276277 :language: python
277278 :copyable:
278- :emphasize-lines: 6-8
279+ :emphasize-lines: 3-6
279280
280281.. tip::
281282
282- To learn more about the ``Meta`` class's ``constraint`` option, see `Constraints
283- <{+django-docs+}/ref/models/constraints/>`__ in the Django documentation.
283+ Setting the ``constraints`` option to a ``UniqueConstraint`` automatically
284+ creates an index on the specified fields. To learn more about the ``Meta``
285+ class's ``constraint`` option, see `Constraints <{+django-docs+}/ref/models/constraints/>`__
286+ in the Django documentation.
284287
285- .. _django-indexes-functions :
288+ .. _django-indexes-expressions :
286289
287- Function Indexes
288- ~~~~~~~~~~~~~~~~
290+ Expression Indexes
291+ ~~~~~~~~~~~~~~~~~~
289292
290293To create indexes on expressions and database functions, pass the
291294``expressions`` argument to the ``models.Index()`` method. When using
0 commit comments