Skip to content

Commit b4227e0

Browse files
author
Sam Kleinman
committed
edits: DOCS-671 minor changes for style of min/max docs
1 parent da9e2be commit b4227e0

File tree

3 files changed

+35
-36
lines changed

3 files changed

+35
-36
lines changed

source/faq/indexes.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ wait for the index to finish building.
109109
Kill the current operation (see :method:`db.killOp()`). The partial
110110
index will be deleted.
111111

112+
.. _faq-index-min-max:
113+
114+
Can I use index keys to constrain query matches?
115+
------------------------------------------------
116+
117+
You can use the :method:`min() <cursor.min()>` and :method:`max()
118+
<cursor.max()>` methods to constrain the results of the cursor returned
119+
from :method:`find() <db.collection.find()>` by using index keys.
120+
112121
Using ``$ne`` and ``$nin`` in a query is slow. Why?
113122
---------------------------------------------------
114123

@@ -117,11 +126,3 @@ See :ref:`index-selectivity`. If you need to use these,
117126
it is often best to make sure that an additional, more selective
118127
criterion is part of the query.
119128

120-
.. _faq-index-min-max:
121-
122-
Can I use index keys to constrain query matches?
123-
------------------------------------------------
124-
125-
You can use the :method:`min() <cursor.min()>` and the :method:`max()
126-
<cursor.max()>` methods to constrain the results of the cursor returned
127-
from :method:`find() <db.collection.find()>` by using the index keys.

source/reference/method/cursor.max.txt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ cursor.max()
2121

2222
.. code-block:: javascript
2323

24-
{ field1: <max value>, field2: <max value2> ... fieldN:<max valueN>}
24+
{ field1: <max value>, field2: <max value2> ... fieldN:<max valueN>}
2525

2626
The fields correspond to *all* the keys of a particular index
2727
*in order*. You can explicitly specify the particular index
@@ -31,9 +31,9 @@ cursor.max()
3131
fields with different sort orders, the selection of the index
3232
may be ambiguous.
3333

34-
Consider the following examples of :method:`max() <cursor.max()>`:
35-
36-
The examples assume a collection ``products`` with the following documents:
34+
Consider the following example of :method:`max() <cursor.max()>`,
35+
which assumes a collection named ``products`` that holds the
36+
following documents:
3737

3838
.. code-block:: javascript
3939

@@ -47,8 +47,8 @@ cursor.max()
4747
{ "_id" : 10, "item" : "orange", "type" : "navel", "price" : 1.39 }
4848
{ "_id" : 9, "item" : "orange", "type" : "satsuma", "price" : 1.99 }
4949
{ "_id" : 8, "item" : "orange", "type" : "valencia", "price" : 0.99 }
50-
51-
The collection has the following four indexes:
50+
51+
The collection has the following indexes:
5252

5353
.. code-block:: javascript
5454

@@ -102,14 +102,14 @@ cursor.max()
102102

103103
.. note::
104104

105-
- Because :method:`max() <cursor.max()>` requires a corresponding
106-
index as well as enforces the use of that index, it may be
107-
preferable to use the :operator:`$lt` operator in the query if
105+
- Because :method:`max() <cursor.max()>` requires an index on a
106+
field, and forces the query to use this index, you may prefer
107+
the :operator:`$lt` operator for the query if
108108
possible. Consider the following example:
109109

110110
.. code-block:: javascript
111111

112-
db.products.find( { _id: 7 } ).max( { price: 1.39 } )
112+
db.products.find( { _id: 7 } ).max( { price: 1.39 } )
113113

114114
The query will use the index on the ``price`` field, even if
115115
the index on ``_id`` may be better.
@@ -124,4 +124,3 @@ cursor.max()
124124

125125
- :method:`max() <cursor.max()>` is a shell wrapper around the
126126
special operator :operator:`$max`.
127-

source/reference/method/cursor.min.txt

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ cursor.min()
2121

2222
.. code-block:: javascript
2323

24-
{ field1: <min value>, field2: <min value2> ... fieldN:<min valueN>}
24+
{ field1: <min value>, field2: <min value2> ... fieldN:<min valueN>}
2525

2626
The fields correspond to *all* the keys of a particular index
2727
*in order*. You can explicitly specify the particular index
2828
with the :method:`hint() <cursor.hint()>` method. Otherwise,
29-
:program:`mongod` selects the index using the fields in the
29+
MongoDB selects the index using the fields in the
3030
``indexbounds``; however, if multiple indexes exist on same
3131
fields with different sort orders, the selection of the index
3232
may be ambiguous.
3333

34-
Consider the following examples of :method:`min() <cursor.min()>`:
35-
36-
The examples assume a collection ``products`` with the following documents:
34+
Consider the following example of :method:`min() <cursor.min()>`,
35+
which assumes a collection named ``products`` that holds the
36+
following documents:
3737

3838
.. code-block:: javascript
3939

@@ -47,8 +47,8 @@ cursor.min()
4747
{ "_id" : 10, "item" : "orange", "type" : "navel", "price" : 1.39 }
4848
{ "_id" : 9, "item" : "orange", "type" : "satsuma", "price" : 1.99 }
4949
{ "_id" : 8, "item" : "orange", "type" : "valencia", "price" : 0.99 }
50-
51-
The collection has the following four indexes:
50+
51+
The collection has the following indexes:
5252

5353
.. code-block:: javascript
5454

@@ -60,13 +60,12 @@ cursor.min()
6060
- Using the ordering of ``{ item: 1, type: 1 }`` index,
6161
:method:`min() <cursor.min()>` limits the query to the documents
6262
that are at or above the index key bound of ``item`` equal to
63-
``apple`` and ``type`` equal to ``jonagold``:
64-
63+
``apple`` and ``type`` equal to ``jonagold``, as in the following:
64+
6565
.. code-block:: javascript
6666

6767
db.products.find().min( { item: 'apple', type: 'jonagold' } ).hint( { item: 1, type: 1 } )
6868

69-
7069
The query returns the following documents:
7170

7271
.. code-block:: javascript
@@ -106,15 +105,15 @@ cursor.min()
106105

107106
.. note::
108107

109-
- Because :method:`min() <cursor.min()>` requires a corresponding
110-
index as well as enforces the use of that index, it may be
111-
preferable to use the :operator:`$gte` operator in the query if
108+
- Because :method:`min() <cursor.min()>` requires an index on a
109+
field, and forces the query to use this index, you may prefer
110+
the :operator:`$gte` operator for the query if
112111
possible. Consider the following example:
113-
112+
114113
.. code-block:: javascript
115-
116-
db.products.find( { _id: 7 } ).min( { price: 1.39 } )
117-
114+
115+
db.products.find( { _id: 7 } ).min( { price: 1.39 } )
116+
118117
The query will use the index on the ``price`` field, even if
119118
the index on ``_id`` may be better.
120119

0 commit comments

Comments
 (0)