@@ -52,19 +52,22 @@ track of the color and quantity, which corresponds to the ``color`` and
52
52
Find Operation
53
53
--------------
54
54
55
- Use the find operation to retrieve a subset of your existing data in
56
- MongoDB. You can specify what data to return including which documents
57
- to retrieve, in what order to retrieve them, and how many to retrieve.
55
+ Use the find operation to retrieve your documents from MongoDB. You can specify
56
+ which documents to retrieve, in what order to retrieve them, and how many to
57
+ retrieve.
58
58
59
59
To perform a find operation, call the ``find()`` method on an instance
60
60
of a ``MongoCollection``. This method searches a collection for documents that
61
61
match the query filter you provide. For more information about how to
62
62
specify a query, see our :ref:`Specify a Query
63
63
<java-query>` guide.
64
64
65
- To retrieve a single document, you can append the ``first()`` method to your
66
- ``find()`` operation. You can use the ``sort()`` operation before selecting the first
67
- document to help choose the correct file.
65
+ To retrieve a single document, you can add the ``first()`` method to your
66
+ ``find()`` call. To choose a specific document, you can use the ``sort()``
67
+ operation before selecting the first document. You may also want to use the
68
+ ``limit()`` method to optimize memory usage. For more information, see the
69
+ server manual for more information about :manual:`memory optimization when using
70
+ the sort operation </reference/operator/aggregation/sort/#-sort----limit-memory-optimization>`.
68
71
69
72
Example
70
73
~~~~~~~
@@ -116,9 +119,9 @@ This example is a complete, standalone file that performs the following actions:
116
119
:language: none
117
120
:visible: false
118
121
119
- Number of documents found with find(): 101
122
+ 10 movies under 15 minutes: 10 Minutes, 3x3, 7:35 in the Morning, 8, 9, A Chairy Tale, A Corner in Wheat, A Gentle Spirit, A Is for Autism, A Movie,
120
123
121
- Document found with find().first() : {"title": "The Room ", "imdb": {"rating": 3.5 , "votes": 25673 , "id": 368226 }}
124
+ The highest rated movie under 15 minutes : {"title": "Andrè and Wally B. ", "imdb": {"rating": 5.4 , "votes": 3294 , "id": 86855 }}
122
125
123
126
.. _retrieve-aggregate:
124
127
@@ -181,6 +184,7 @@ on this page, see the following API documentation:
181
184
182
185
- `find() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#find()>`__
183
186
- `first() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoIterable.html#first()>`__
187
+ - `limit() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/FindIterable.html#limit(int)>`__
184
188
- `FindIterable <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/FindIterable.html>`__
185
189
- `aggregate() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#aggregate(java.util.List)>`__
186
190
@@ -190,4 +194,6 @@ Server Manual Entries
190
194
- :manual:`Collections </core/databases-and-collections/#collections>`
191
195
- :manual:`Query Documents </tutorial/query-documents>`
192
196
- :manual:`Aggregation </aggregation>`
197
+ - :manual:`$sort </aggregation/sort>`
198
+ - :manual:`$limit </aggregation/limit>`
193
199
- :manual:`Aggregation stages </meta/aggregation-quick-reference/#stages>`
0 commit comments