Skip to content

Commit a5f5e38

Browse files
authored
DOCSP-38471 adding query on nested fields example (#618)
* DOCSP-38471 adding query on nested fields example * DOCSP-38471 adding query on nested fields example * DOCSP-38471 adding query on nested fields example * DOCSP-38471 copy edits * DOCSP-38471 removing line emphasis * DOCSP-38471 changing emphasis
1 parent 7e583b1 commit a5f5e38

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

source/query/filter.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ sample data into your MongoDB deployment, perform the following steps:
7575
{
7676
"name": "Andrea Le",
7777
"email": "[email protected]",
78+
"school": {
79+
"name": "Northwestern"
80+
},
7881
"version": 5,
7982
"scores": [ 85, 95, 75 ],
8083
"dateCreated": { "$date": "2003-03-26" }
@@ -134,6 +137,9 @@ The query returns the following document:
134137
"_id": { "$oid": "5e349915cebae490877d561d" },
135138
"name": "Andrea Le",
136139
"email": "[email protected]",
140+
"school": {
141+
"name": "Northwestern"
142+
},
137143
"version": 5,
138144
"scores": [ 85, 95, 75 ],
139145
"dateCreated": { "$date": "2003-03-26" }
@@ -183,6 +189,9 @@ The query returns the following documents:
183189
"_id": { "$oid": "5e349915cebae490877d561d" },
184190
"name": "Andrea Le",
185191
"email": "[email protected]",
192+
"school": {
193+
"name": "Northwestern"
194+
},
186195
"version": 5,
187196
"scores": [ 85, 95, 75 ],
188197
"dateCreated": { "$date": "2003-03-26" }
@@ -295,6 +304,9 @@ The query returns the following documents:
295304
"_id": { "$oid": "5e349915cebae490877d561d" },
296305
"name": "Andrea Le",
297306
"email": "[email protected]",
307+
"school": {
308+
"name": "Northwestern"
309+
},
298310
"version": 5,
299311
"scores": [ 85, 95, 75 ],
300312
"dateCreated": { "$date": "2003-03-26" }
@@ -329,6 +341,9 @@ in the ``scores`` array is ``85``:
329341
"_id": { "$oid": "5e349915cebae490877d561d" },
330342
"name": "Andrea Le",
331343
"email": "[email protected]",
344+
"school": {
345+
"name": "Northwestern"
346+
},
332347
"version": 5,
333348
"scores": [ 85, 95, 75 ],
334349
"dateCreated": { "$date": "2003-03-26" }
@@ -359,11 +374,44 @@ The query returns the following document:
359374
"_id": { "$oid": "5e349915cebae490877d561d" },
360375
"name": "Andrea Le",
361376
"email": "[email protected]",
377+
"school": {
378+
"name": "Northwestern"
379+
},
362380
"version": 5,
363381
"scores": [ 85, 95, 75 ],
364382
"dateCreated": { "$date": "2003-03-26" }
365383
}
366384

385+
Match by Embedded Field
386+
~~~~~~~~~~~~~~~~~~~~~~~
387+
388+
The following query filter finds the
389+
document with the ``school.name`` subfield of "Northwestern":
390+
391+
.. code-block:: shell
392+
393+
{ "school.name": "Northwestern" }
394+
395+
396+
The query returns the following document:
397+
398+
.. code-block:: JSON
399+
:copyable: false
400+
:emphasize-lines: 6
401+
402+
{
403+
"_id": { "$oid": "5e349915cebae490877d561d" },
404+
"name": "Andrea Le",
405+
"email": "[email protected]",
406+
"school": {
407+
"name": "Northwestern"
408+
},
409+
"version": 5,
410+
"scores": [ 85, 95, 75 ],
411+
"dateCreated": { "$date": "2003-03-26" }
412+
}
413+
414+
367415
For more query examples, see
368416
:manual:`Query Documents </tutorial/query-documents/>`
369417
in the MongoDB manual.

0 commit comments

Comments
 (0)