For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

How to Run MongoDB Search Queries Against Fields in Embedded Documents

This tutorial demonstrates how to index and run MongoDB Search queries against fields that are inside an array of documents, even when the array of documents is nested itself. To enable queries against these fields, you index the document fields as the embeddedDocuments type.

The tutorial on this page demonstrates queries against fields in the following types of arrays:

  • Array of documents.

  • Array of documents inside a document.

  • Array of documents inside an array of documents.

Before you begin, ensure that your cluster meets the requirements described in the Prerequisites.

This tutorial demonstrates sample MongoDB Search queries against fields in embedded documents. To learn more about these queries, see About this Tutorial.