Docs Menu

Docs HomeDevelop ApplicationsMongoDB Manual

Query on Embedded/Nested Documents

On this page

  • Query on Nested Field with Dot Notation
  • Match an Embedded/Nested Document
  • Query Embedded Documents with MongoDB Atlas
  • Additional Query Tutorials

You can query embedded documents in MongoDB by using the following methods:

  • Your programming language's driver.

  • The MongoDB Atlas UI. To learn more, see Query Embedded Documents with MongoDB Atlas.

  • MongoDB Compass.

Use the Select your language drop-down menu in the upper-right to set the language of the following examples or select MongoDB Compass.

To specify a query condition on fields in an embedded/nested document, use dot notation ("field.nestedField").


When querying using dot notation, the field and nested field must be inside quotation marks.

The following example selects all documents where the field uom nested in the size field equals "in":

The following query uses the less than operator ($lt) on the field h embedded in the size field:

The following query selects all documents where the nested field h is less than 15, the nested field uom equals "in", and the status field equals "D":

For example, the following query selects all documents where the field size equals the document { h: 14, w: 21, uom: "cm" }:


MongoDB does not recommend equality matches on embedded documents because the operations require an exact match of the specified <value> document, including the field order.

For example, the following query does not match any documents in the inventory collection:

The result of queries that use equality matches on embedded documents is undefined when used with a driver that does not use ordered data structures for expressing queries.

The example in this section uses the sample movies dataset. To learn how to load the sample dataset into your MongoDB Atlas deployment, see Load Sample Data.

To query an embedded document in MongoDB Atlas, follow these steps:

  1. In the MongoDB Atlas UI, click Database in the sidebar.

  2. For the database deployment that contains the sample data, click Browse Collections.

  3. In the left navigation pane, select the sample_mflix database.

  4. Select the movies collection.


Specify the query filter document in the Filter field. A query filter document uses query operators to specify search conditions.

Copy the following query filter document into the Filter search bar:

{ "awards.wins": 1 }

This query filter returns all documents in the sample_mflix.movies collection where the embedded document for the awards field contains { wins: 1 }.

For additional query examples, see:

← Query Documents