Skip to content

Commit 27f70fd

Browse files
committed
Feedback
1 parent ef83faf commit 27f70fd

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

source/includes/reference/indexes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Restaurant
4242
include Mongoid::Document
4343

4444
field :name, type: String
45-
embeds_many :addresses
45+
field :borough, type: String
4646

4747
index({borough: 1, name: -1}, { name: "compound_index"})
4848
end

source/reference/indexes.txt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

4653
The ``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

4956
When 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
5158
descending index. The second hash object contains index options. To learn more
5259
about index options, see the :ref:`mongoid-indexes-api-documentation` section.
5360

5461
Aliases and Declaring Indexes
5562
+++++++++++++++++++++++++++++
5663

5764
You 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``
5966
field:
6067

6168
.. literalinclude:: /includes/reference/indexes.rb
@@ -67,9 +74,8 @@ Create an Index on Embedded Document Fields
6774
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6875

6976
You 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

8288
You 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``
8490
field 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

104110
For 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

107113
For 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

110116
Create 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

121127
For 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

124130
Create Multiple Indexes
125131
~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)