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