@@ -6,6 +6,13 @@ Work With Indexes
66
77.. default-domain:: mongodb
88
9+ .. facet::
10+ :name: genre
11+ :values: reference
12+
13+ .. meta::
14+ :keywords: code example, odm, optimization, efficiency, Atlas search
15+
916.. contents:: On this page
1017 :local:
1118 :backlinks: none
@@ -44,18 +51,18 @@ named ``cuisine_index`` on the ``cuisine`` field in the ``Restaurant`` class:
4451 :end-before: end create index
4552
4653The ``index`` macro defines the index you want to create and the ``create_indexes``
47- macro creates the index in the ``restaurants`` collection.
54+ macro creates it in the ``restaurants`` collection.
4855
4956When defining an index, the first hash object contains the field you want to
50- index and its direction. ``1`` represents an ascending index, ``-1`` represents a
57+ index and its direction. ``1`` represents an ascending index, and ``-1`` represents a
5158descending index. The second hash object contains index options. To learn more
5259about index options, see the :ref:`mongoid-indexes-api-documentation` section.
5360
5461Aliases and Declaring Indexes
5562+++++++++++++++++++++++++++++
5663
5764You can use aliased field names in index definitions. For example, the following
58- example creates a field on the ``b`` field, which is an alias of the ``borough``
65+ code creates a field on the ``b`` field, which is an alias of the ``borough``
5966field:
6067
6168.. literalinclude:: /includes/reference/indexes.rb
@@ -67,9 +74,8 @@ Create an Index on Embedded Document Fields
6774~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6875
6976You can define an index on embedded document fields. The following code example
70- shows how to declare an ascending index on the ``street`` field in the
71- ``Restaurant`` class where ``street`` is a field embedded within the ``address``
72- field.
77+ shows how to declare an ascending index on the ``street`` field, which is embedded
78+ within the ``address`` field in the ``Restaurant`` model.
7379
7480.. literalinclude:: /includes/reference/indexes.rb
7581 :language: ruby
@@ -80,7 +86,7 @@ Create a Compound Index
8086~~~~~~~~~~~~~~~~~~~~~~~
8187
8288You can define a compound index on multiple fields. The following code example
83- shows how to declare a compound index that is ascending on the ``address.street ``
89+ shows how to declare a compound index that is ascending on the ``borough ``
8490field and descending on the ``name`` field.
8591
8692.. literalinclude:: /includes/reference/indexes.rb
@@ -102,10 +108,10 @@ objects:
102108 :end-before: end create 2dsphere index
103109
104110For more information on 2dsphere indexes, see the :manual:`2dsphere </core/indexes/index-types/geospatial/2dsphere/>`
105- guide in the {+mdb- server+} manual .
111+ guide in the MongoDB {+ server-manual+} .
106112
107113For more information on the GeoJSON type, see the :manual:`GeoJSON Objects </reference/geojson/>`
108- guide in the {+mdb- server+} manual .
114+ guide in the MongoDB {+ server-manual+} .
109115
110116Create a Sparse Index
111117~~~~~~~~~~~~~~~~~~~~~
@@ -119,7 +125,7 @@ The following code example defines a sparse index on the ``borough`` field:
119125 :end-before: end create sparse index
120126
121127For more information on sparse indexes, see the :manual:`Sparse Indexes </core/index-sparse/>`
122- guide in the {+mdb- server+} manual .
128+ guide in the MongoDB {+ server-manual+} .
123129
124130Create Multiple Indexes
125131~~~~~~~~~~~~~~~~~~~~~~~
0 commit comments