Docs Menu

Docs HomeLaunch & Manage MongoDBMongoDB Atlas


On this page

  • Definition
  • Syntax
  • Options
  • Behavior
  • Scoring Behavior
  • Highlighting
  • Limitations
  • Examples


The Atlas Search embeddedDocuments index option, embeddedDocument operator, and embedded scoring option are in preview. When an Atlas Search index on a replica set or single MongoDB shard reaches Lucene's two billion document limit, Atlas Search doesn't index new documents or apply updates to existing documents for that index. A solution to accommodate this limitation will be in place when this feature is generally available. To troubleshoot any issues related to using this feature, contact Support.


The embeddedDocument operator is similar to $elemMatch operator. It constrains multiple query predicates to be satisfied from a single element of an array of embedded documents. embeddedDocument can be used only for queries over fields of the embeddedDocuments type.

embeddedDocument has the following syntax:

"embeddedDocument": {
"path": "<path-to-field>",
"operator": { <operator-specification> },
"score": { <score-options> }

embeddedDocument uses the following options to construct a query:

Operator to use to query each document in the array of documents that you specify in the path. The moreLikeThis operator is not supported.
Indexed embeddedDocuments type field to search. The specified field must be a parent for all operators and fields specified using the operator option. See Path Construction for more information.
Score to assign to matching search results. You can use the embedded scoring option to configure scoring options. To learn more, see Scoring Behavior.

When you query embedded documents in arrays using the embeddedDocument operator, Atlas Search evaluates and scores the operator query predicates at different stages of query execution. Atlas Search:

  1. Evaluates each embedded document in the array independently.

  2. Combines the scores of matching results as configured using the embedded option, or scores by summing the scores of matching results if you don't specify an embedded score option.

  3. Joins the matching results with the parent document if other query predicates are specified through the compound operator.


    For string faceting, Atlas Search counts string facets once for each document in the result set. For an example of this behavior, see Examples.

By default, embeddedDocument operator uses the default aggregation strategy, sum, for combining scores of embedded document matches. The embeddedDocument operator score option allows you to override the default and configure the score of matching results using the embedded option.


See also:

You can highlight on fields if the fields are indexed under a parent field of document type for query predicates specified inside the embeddedDocument operator. For an example, see tutorial.

You can't highlight on queries inside the embeddedDocument operator.

The following examples use the sample_supplies.sales collection in the sample dataset. These examples use the following index definition on the collection:

"mappings": {
"dynamic": true,
"fields": {
"items": {
"dynamic": true,
"type": "embeddedDocuments"
"purchaseMethod": {
"type": "stringFacet"
←  compoundequals →