forked from mongodb/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery.txt
353 lines (202 loc) · 6.5 KB
/
query.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
.. _query-projection-operators-top:
==============================
Query and Projection Operators
==============================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. include:: /includes/extracts/operators-toc-explanation.rst
.. _query-selectors:
Query Selectors
---------------
Comparison
~~~~~~~~~~
.. include:: /includes/fact-comparison-order.rst
.. list-table::
:widths: 30,70
:header-rows: 1
* - Name
- Description
* - :query:`$eq`
- Matches values that are equal to a specified value.
* - :query:`$gt`
- Matches values that are greater than a specified value.
* - :query:`$gte`
- Matches values that are greater than or equal to a specified value.
* - :query:`$in`
- Matches any of the values specified in an array.
* - :query:`$lt`
- Matches values that are less than a specified value.
* - :query:`$lte`
- Matches values that are less than or equal to a specified value.
* - :query:`$ne`
- Matches all values that are not equal to a specified value.
* - :query:`$nin`
- Matches none of the values specified in an array.
.. toctree::
:titlesonly:
:hidden:
/reference/operator/query-comparison
Logical
~~~~~~~
.. list-table::
:widths: 30,70
:header-rows: 1
* - Name
- Description
* - :query:`$and`
- Joins query clauses with a logical ``AND`` returns all documents that match the conditions of both clauses.
* - :query:`$not`
- Inverts the effect of a query expression and returns documents that do *not* match the query expression.
* - :query:`$nor`
- Joins query clauses with a logical ``NOR`` returns all documents that fail to match both clauses.
* - :query:`$or`
- Joins query clauses with a logical ``OR`` returns all documents that match the conditions of either clause.
.. toctree::
:titlesonly:
:hidden:
/reference/operator/query-logical
Element
~~~~~~~
.. list-table::
:widths: 30,70
:header-rows: 1
* - Name
- Description
* - :query:`$exists`
- Matches documents that have the specified field.
* - :query:`$type`
- Selects documents if a field is of the specified type.
.. toctree::
:titlesonly:
:hidden:
/reference/operator/query-element
Evaluation
~~~~~~~~~~
.. list-table::
:widths: 30,70
:header-rows: 1
* - Name
- Description
* - :query:`$expr`
- Allows use of aggregation expressions within the query language.
* - :query:`$jsonSchema`
- Validate documents against the given JSON Schema.
* - :query:`$mod`
- Performs a modulo operation on the value of a field and selects documents with a specified result.
* - :query:`$regex`
- Selects documents where values match a specified regular expression.
* - :query:`$text`
- Performs text search.
* - :query:`$where`
- Matches documents that satisfy a JavaScript expression.
.. toctree::
:titlesonly:
:hidden:
/reference/operator/query-evaluation
Geospatial
~~~~~~~~~~
.. list-table::
:widths: 30,70
:header-rows: 1
* - Name
- Description
* - :query:`$geoIntersects`
- Selects geometries that intersect with a :term:`GeoJSON` geometry.
The :doc:`2dsphere </core/2dsphere>` index supports
:query:`$geoIntersects`.
* - :query:`$geoWithin`
- Selects geometries within a bounding :ref:`GeoJSON geometry
<geospatial-indexes-store-geojson>`. The :doc:`2dsphere
</core/2dsphere>` and :doc:`2d </core/2d>` indexes support
:query:`$geoWithin`.
* - :query:`$near`
- Returns geospatial objects in proximity to a point.
Requires a geospatial index. The :doc:`2dsphere
</core/2dsphere>` and :doc:`2d </core/2d>` indexes support
:query:`$near`.
* - :query:`$nearSphere`
- Returns geospatial objects in proximity to a point on a sphere.
Requires a geospatial index. The :doc:`2dsphere
</core/2dsphere>` and :doc:`2d </core/2d>` indexes support
:query:`$nearSphere`.
.. toctree::
:titlesonly:
:hidden:
/reference/operator/query-geospatial
.. _operator-query-array:
Array
~~~~~
.. list-table::
:widths: 30,70
:header-rows: 1
* - Name
- Description
* - :query:`$all`
- Matches arrays that contain all elements specified in the query.
* - :query:`$elemMatch`
- Selects documents if element in the array field matches all the specified :query:`$elemMatch` conditions.
* - :query:`$size`
- Selects documents if the array field is a specified size.
.. toctree::
:titlesonly:
:hidden:
/reference/operator/query-array
Bitwise
~~~~~~~
.. list-table::
:widths: 30,70
:header-rows: 1
* - Name
- Description
* - :query:`$bitsAllClear`
- Matches numeric or binary values in which a set of bit positions *all* have a value of ``0``.
* - :query:`$bitsAllSet`
- Matches numeric or binary values in which a set of bit positions *all* have a value of ``1``.
* - :query:`$bitsAnyClear`
- Matches numeric or binary values in which *any* bit from a set of bit positions has a value of ``0``.
* - :query:`$bitsAnySet`
- Matches numeric or binary values in which *any* bit from a set of bit positions has a value of ``1``.
.. toctree::
:titlesonly:
:hidden:
/reference/operator/query-bitwise
.. _query-projection-operators:
Projection Operators
--------------------
.. list-table::
:widths: 30,70
:header-rows: 1
* - Name
- Description
* - :projection:`$`
- Projects the first element in an array that matches the query condition.
* - :projection:`$elemMatch`
- Projects the first element in an array that matches the specified :projection:`$elemMatch` condition.
* - :expression:`$meta`
- Projects the document's score assigned during :query:`$text` operation.
* - :projection:`$slice`
- Limits the number of elements projected from an array. Supports skip and limit slices.
.. toctree::
:titlesonly:
:hidden:
/reference/operator/projection
.. _query-miscelaneous-operators:
Miscellaneous Operators
-----------------------
.. list-table::
:widths: 25,75
:header-rows: 1
* - Name
- Description
* - :query:`$comment`
- Adds a comment to a query predicate.
* - :query:`$rand`
- Generates a random float between 0 and 1.
.. toctree::
:titlesonly:
:hidden:
/reference/operator/query-miscellaneous