Navigation

Explain

Important

You can run Atlas Search queries with explain in mongo shell. However, it is not available for MongoDB Compass.

The Atlas Search query returns information about the $search query plan and execution statistics when the query is run with the explain method. When you run a query with explain, Atlas Search returns a BSON document containing information about how the query was run.

Tip
See also:
db.<myCollection>.explain("<verbosity>").aggregate([
{
$search: {
"<operator>": {
"<operator-options>"
}
}
}
])

Verbosity mode controls the behavior of explain and the amount of information returned. Value can be one of the following:

queryPlanner (default)
Information about the query plan. Does not include the stats field, which contains execution statistics for the query.
Information about the query plan including the stats field, which contains execution statistics for the query.
Information about the query plan including the stats field, which contains execution statistics for the query.
Tip
See also:

The explain response is a BSON document with keys and values describing the execution statistics for the query. The explain document in the result set contains the following fields:

Option
Type
Necessity
Purpose
path
string
Optional
Path to the operator, only if it isn't the root.
type
string
Required
Name of the Lucene Query that the Atlas Search operator created. See Lucene Query Structured Summary for more information.
analyzer
string
Optional
Atlas Search analyzer used with the query.
args
document
Required
Lucene query information. See Lucene Query Structured Summary for more information.
stats
document
Optional
Explain Timing Breakdown for the query if explain ran with executionStats or allPlansExecution verbosity.

The following examples use the sample_mflix.movies collection.

Give Feedback

On this page

  • Syntax
  • Verbosity
  • Explain Response
  • Examples