Docs Menu

Retrieve Query Plan and Execution Statistics

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

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, in order of decreasing verbosity:

Information about the query plan including the stats fields, which contain execution statistics for the query. Includes partial execution data captured during plan selection.

Information about the query plan including the stats fields, which contain execution statistics for the query.

queryPlanner (default)

Information about the query plan. Does not include the stats fields, which contain execution statistics for the query.

See also:

The explain method returns a BSON document with the following fields.

Option
Type
Necessity
Purpose

collectors

document

Optional

Describes the execution statistics for the collector. If indexPartitionExplain is present, this is nested within each indexPartitionExplain instead of at the top-level.

highlight

document

Optional

Details about the highlight execution for the query. This is returned only if you specified highlighting in the query.

indexPartitionExplain

array of documents

Optional

Contains per index partition details. This is only returned if you configured two or more index partitions.

metadata

document

Optional

Contains useful metadata.

query

document

Optional

Describes the execution statistics for the query. This is not If indexPartitionExplain is present, this is nested within each indexPartitionExplain, instead of at the top-level.

resultMaterialization

document

Optional

Details related to retrieving per-document data from Lucene after query execution. This is not returned for queryPlanner verbosity mode.

resourceUsage

document

Optional

Details the resource usage of the query when it was executed. This is not returned for queryPlanner verbosity mode.

The collectors BSON document contains the following fields:

Field
Type
Necessity
Purpose

allCollectorStats

document

Required

Statistics of all collectors of the query. Statistics reported represent either the maximum value across all collectors used in the query or a sum of the statistic across all the sub-collectors. The timing statistics are summed to reflect the total time spent across all collectors for the entire query. To learn more, see allCollectorStats.

facet

document

Optional

Breakdown of the query that specifies facet. To learn more, see facet.

sort

document

Optional

Breakdown of the query that specifies sort. To learn more, see sort.

The allCollectorStats BSON document describes collector statistics across all collectors specified in the query, including facet and sort. It contains the following keys:

Field
Description

collect

Tracks the duration and number of results collected by the collector.

competitiveIterator

Statistics tracking the total duration and the number of times a competitiveIterator was requested from the collector.

setScorer

Statistics tracking the total duration and number of times a scorer was set on the collector.

The facet is a BSON document that details query and execution statistics when you specify a facet in the query. It contains the following fields:

Option
Type
Necessity
Purpose

collectorStats

document

Optional

Shows statistics only for the facet collector. The keys in here are identical to the allCollectorStats. You can evaluate the difference between this and the allCollectorStats to determine the sort collector execution statistics if you used sort in the query.

createCountsStats

document

Optional

Shows statistics related to creating the internal Lucene object that holds all of the facet groupings. It contains generateFacetCounts field, which returns the statistics tracking the total duration and number of times mongot generates the Lucene object that holds all of the facets and their counts.

stringFacetFieldCardinalities

document

Required

Maps the field being faceted on to their cardinalities for both the documents that matched the query and across the entire Lucene index. It provides the following cardinality information for each field:

  • queried - Represents the facet cardinality of the field across all queried documents.

  • total - Represents the facet cardinality of the field across all documents in the index.

The sort is a BSON document that details query and execution statistics when you specify a sort in the query. It contains the following fields:

Option
Type
Necessity
Purpose

stats

document

Optional

Tracks statistics related to sort execution across all sort fields. It contains the following fields:

  • comparator - Shows statistics and metadata around how the Lucene sorts the results.

    • setBottom - Returns how often the current least competitive sort value is updated with a new and more competitive value. When sorting, Atlas Search keeps track of the bottom value and if a new value surpasses the current bottom value in relevance or competitiveness, this metric is incremented.

    • compareBottom - Returns the timing and invocation statistics related to comparing the current bottom value with a candidate bottom value.

    • compareTop - Returns the timing and invocation statistics related to comparing the current top value with a candidate top value.

    • setHitsThresholdReached - Returns the timing and invocation statistics related to when the maximum number of results (limit) was reached.

    • competitiveIterator - Returns the the timing and invocation statistics related to iterating (only) over documents that are likely to compete for top spots in the sorted results.

    • setScorer - Returns the the timing and invocation statistics related to computing the score and relevance of documents.

  • prunedResultIterator - Shows the invocations and timing statistics of nextDoc and advance method calls on Lucene's competitiveIterator.

    This is not present in the output if it performs a mixed data type sort.

    It contains only the nextDoc field.

fieldInfos

document

Required

Maps the field being sorted on to the list of data types present in the index for the field.

The highlight is a BSON document that details query and execution statistics when you specify highlighting in the query. It contains the following fields:

Option
Type
Necessity
Purpose

resolvedHighlightPaths

List<String>

Required

List of all the highlighted fields. If you specified a wildcard path in the highlight section of your query, contains a list of fully resolved document paths.

stats

QueryExecutionArea

Optional

Invocation and timing statistics related to setting up and executing highlights. It contains the following fields:

  • setupHighlight - Time it took for setting up the internal Lucene objects used during the executeHighlight phase.

  • executeHighlight - Time it took to run highlighting over the matching documents.

the indexPartitionExplain contains Explain Results for each index partition. The top-level collectors and query are inside the explain information of each index partition and absent at the top-level.

The metadata contains helpful metadata, such as the following:

Field
Type
Necessity
Purpose

mongotVersion

String

Optional

Current version of mongot.

mongotHostName

String

Optional

Human readable label that identifies the mongot host.

indexName

String

Optional

Atlas Search index used in the query.

cursorOptions

Document

Optional

Cursor options given to mongot.

totalLuceneDocs

Integer

Optional

Total number of index objects in the index including deleted documents.

The query BSON document describes the execution statistics for the query. It contains the following fields:

Field
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 query for more information.

analyzer

string

Optional

Atlas Search analyzer used with the query.

args

document

Required

Lucene query information. See query for more information.

stats

document

Optional

stats for the query if explain ran with executionStats or allPlansExecution verbosity.

The explain response of a search command contains information about the query executed with that command. The response in the args field includes structured details of what Lucene queries Atlas Search executed to satisfy a $search query.

This section contains:

  • Some of the Lucene queries that Atlas Search operators create

  • Lucene query options that are included in the structured summary

  • Lucene query structured summary example for each Lucene query type

Note

About the Examples

The examples in this section are based on queries run against the sample datasets with the queryPlanner verbosity mode. In the example response, the:

  • mongotQuery field shows the Atlas Search operator and the query that was run.

  • explain.type field shows the Lucene Query that the operator created.

For complete examples, see Examples.

BooleanQuery

For Lucene BooleanQuery, the structured summary includes details on the following options:

Field
Type
Necessity
Description

must

Optional

Clauses which must match.

mustNot

Optional

Clauses which must not match.

should

Optional

Clauses which should match.

filter

Optional

Clauses which must all match.

minimumShouldMatch

Integer

Optional

The minimum number of should clauses which must match.

ConstantScoreQuery

For constant score queries, the structured summary includes details on the following options:

Field
Type
Necessity
Description

query

Required

Child of the ConstantScoreQuery.

The following example shows the explain response for a query run against the sample_airbnb.listingsAndReviews collection.

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "equals" : {
7 "path" : "host.host_identity_verified",
8 "value" : true
9 }
10 },
11 "explain" : {
12 "type" : "ConstantScoreQuery",
13 "args" : {
14 "query" : {
15 "type" : "TermQuery",
16 "args" : {
17 "path" : "host.host_identity_verified",
18 "value" : "T"
19 }
20 }
21 }
22 }
23 }
24 },
25 {
26 "$_internalSearchIdLookup" : { }
27 }
28 ],
29 ...
30}
FunctionScoreQuery

For Lucene FunctionScoreQuery queries, the structured summary includes details on the following options:

Field
Type
Necessity
Description

scoreFunction

string

Required

Scoring expression used in the query.

query

Required

The query.

The following example shows the explain response for a query run against the sample_airbnb.listingsAndReviews collection.

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "near" : {
7 "path" : "accomodates",
8 "origin" : 8,
9 "pivot" : 2
10 }
11 },
12 "explain" : {
13 "type" : "BooleanQuery",
14 "args" : {
15 "must" : [ ],
16 "mustNot" : [ ],
17 "should" : [
18 {
19 "type" : "BooleanQuery",
20 "args" : {
21 "must" : [ ],
22 "mustNot" : [ ],
23 "should" : [
24 {
25 "type" : "FunctionScoreQuery",
26 "args" : {
27 "scoreFunction" : "expr(pivot / (pivot + abs(origin - value)))",
28 "query" : {
29 "type" : "LongDistanceFeatureQuery",
30 "args" : { },
31 "stats" : { }
32 }
33 }
34 }
35 ],
36 "filter" : [
37 {
38 "type" : "PointRangeQuery",
39 "args" : {
40 "path" : "accomodates",
41 "representation" : "double",
42 "gte" : 8.000000000000002,
43 "lte" : NaN
44 }
45 }
46 ],
47 "minimumShouldMatch" : 0
48 }
49 },
50 {
51 "type" : "LongDistanceFeatureQuery",
52 "args" : { },
53 "stats" : { }
54 }
55 ],
56 "filter" : [ ],
57 "minimumShouldMatch" : 0
58 }
59 }
60 },
61 ...
62 },
63 ...
64 ],
65 ...
66}
LatLonPointDistanceQuery

For Lucene LatLonPointDistanceQuery queries, the response contains an stats only.

The following example shows the explain response for a query run against the sample_airbnb.listingsAndReviews collection.

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "geoWithin" : {
7 "path" : "address.location",
8 "circle" : {
9 "radius" : 4800,
10 "center" : {
11 "type" : "Point",
12 "coordinates" : [
13 -122.419472,
14 37.765302
15 ]
16 }
17 }
18 }
19 },
20 "explain" : {
21 "type" : "LatLonPointDistanceQuery",
22 "args" : { }
23 }
24 }
25 },
26 ...
27 ],
28 ...
29}
LatLonShapeQuery

For Lucene LatLonShapeQuery queries, the response contains an stats only.

The following example shows the explain response for a query run against the sample_airbnb.listingsAndReviews collection.

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "geoShape" : {
7 "path" : "address.location",
8 "relation" : "within",
9 "geometry" : {
10 "type" : "Polygon",
11 "coordinates" : [
12 [
13 [ -74.3994140625, 40.5305017757 ],
14 [ -74.7290039063, 40.5805846641 ],
15 [ -74.7729492188, 40.9467136651 ],
16 [ -74.0698242188, 41.1290213475 ],
17 [ -73.65234375, 40.9964840144 ],
18 [ -72.6416015625, 40.9467136651 ],
19 [ -72.3559570313, 40.7971774152 ],
20 [ -74.3994140625, 40.5305017757 ]
21 ]
22 ]
23 }
24 }
25 },
26 "explain" : {
27 "type" : "LatLonShapeQuery",
28 "args" : { }
29 }
30 },
31 ...
32 },
33 ...
34 ],
35 ...
36}
LongDistanceFeatureQuery

For Lucene LongDistanceFeatureQuery, the response contains an stats only.

The following example shows the explain response for a query run against the sample_mflix.movies collection.

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "near" : {
7 "path" : "released",
8 "origin" : ISODate("1915-09-13T00:00:00Z"),
9 "pivot" : 7776000000
10 }
11 },
12 "explain" : {
13 "type" : "LongDistanceFeatureQuery",
14 "args" : { }
15 }
16 },
17 ...
18 },
19 ...
20 ],
21 ...
22}
MultiTermQueryConstantScoreWrapper

For Lucene MultiTermQueryConstantScoreWrapper queries, the structured summary includes details on the following arguments:

Field
Type
Necessity
Description

queries

Required

List of queries.

The following example shows the explain response for a query run against the sample_airbnb.listingsAndReviews collection.

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "regex" : {
7 "path" : "access",
8 "query" : "full(.{0,5})",
9 "allowAnalyzedField" : true
10 }
11 },
12 "explain" : {
13 "type" : "MultiTermQueryConstantScoreWrapper",
14 "args" : {
15 "queries" : [
16 {
17 "type" : "DefaultQuery",
18 "args" : {
19 "queryType" : "RegexpQuery"
20 }
21 }
22 ]
23 }
24 }
25 },
26 ...
27 },
28 ...
29 ],
30 ...
31}
PhraseQuery

For Lucene PhraseQuery queries, the structured summary includes details on the following arguments:

Field
Type
Necessity
Description

path

String

Required

Indexed field to search.

query

String

Required

String or strings to search for.

slop

Number

Required

Allowable distance between words in the query phrase.

The following example shows the explain response for a query run against the sample_airbnb.listingsAndReviews collection.

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "phrase" : {
7 "path" : "description",
8 "query" : "comfortable apartment",
9 "slop" : 2
10 }
11 },
12 "explain" : {
13 "type" : "PhraseQuery",
14 "args" : {
15 "path" : "description",
16 "query" : "[comfortable, apartment]",
17 "slop" : 2
18 }
19 }
20 },
21 ...
22 },
23 ...
24 ],
25 ...
26}
PointRangeQuery

For Lucene PointRangeQuery queries, the structured summary includes details on the following arguments:

Field
Type
Necessity
Description

path

String

Required

Indexed field to search.

representation

String

Optional

Numeric representation. Queries over date-typed data do not include representation.

gte

Number

Optional

Lower bound of the query.

lte

Number

Optional

Upper bound of the query.

The following example shows the explain response for a query run against the sample_airbnb.listingsAndReviews collection.

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "range" : {
7 "path" : "number_of_reviews",
8 "gt" : 5
9 }
10 },
11 "explain" : {
12 "type" : "BooleanQuery",
13 "args" : {
14 "must" : [ ],
15 "mustNot" : [ ],
16 "should" : [
17 {
18 "type" : "PointRangeQuery",
19 "args" : {
20 "path" : "number_of_reviews",
21 "representation" : "double",
22 "gte" : 5.000000000000001
23 }
24 },
25 {
26 "type" : "PointRangeQuery",
27 "args" : {
28 "path" : "number_of_reviews",
29 "representation" : "int64",
30 "gte" : NumberLong(6)
31 }
32 }
33 ],
34 "filter" : [ ],
35 "minimumShouldMatch" : 0
36 }
37 }
38 },
39 ...
40 },
41 ...
42 ],
43 ...
44}
TermQuery

For term queries, the structured summary includes details on the following arguments:

Field
Type
Necessity
Description

path

String

Required

Indexed field to search.

value

String

Required

String to search for.

The following example shows the explain response for a query run against the sample_airbnb.listingsAndReviews collection.

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "queryString" : {
7 "defaultPath" : "summary",
8 "query" : "quiet"
9 }
10 },
11 "explain" : {
12 "type" : "TermQuery",
13 "args" : {
14 "path" : "summary",
15 "value" : "quiet"
16 }
17 }
18 },
19 ...
20 },
21 ...
22 ],
23 ...
24}
Default

Lucene queries that are not explicitly defined by another Lucene query are serialized using the default query. The structured summary includes details on the following option:

Field
Type
Necessity
Description

queryType

String

Required.

Type of Lucene query.

The following example shows the explain response for a query run against the sample_airbnb.listingsAndReviews collection.

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "near" : {
7 "origin" : {
8 "type" : "Point",
9 "coordinates" : [
10 -8.61308,
11 41.1413
12 ]
13 },
14 "pivot" : 1000,
15 "path" : "address.location"
16 }
17 },
18 "explain" : {
19 "type" : "DefaultQuery",
20 "args" : {
21 "queryType" : "LatLonPointDistanceFeatureQuery"
22 }
23 }
24 },
25 ...
26 },
27 ...
28 ],
29 ...
30}

The explain response for executionStats and allPlansExecution verbosity modes includes a stats field that contains information on how much time a query spends in various stages of query execution.

The timing breakdown describes execution statistics pertinent to an areas of query execution. The following fields show the timing breakdown:

Field
Type
Description

millisElapsed

Long

Approximate wall-clock time elapsed performing tasks in this area including the amount of time the children of the query spent in this area. The value is approximate number of milliseconds elapsed while performing tasks in this area.

invocationCounts

Document

Number of invocations of tasks included in this area. The value is a map of task names to their invocation count.

Statistics are available for the following areas of query:

Option
Description

context

Statistics related to the execution of the Lucene query. There are two tasks whose invocation counts are enumerated in this area:

createScorer

Scorer iterates over documents and generates a score for each document. Invocations of createScorer create the object responsible for scoring. Note that time associated with this task is not time spent actually scoring documents. Count includes the number of scorerSupplier invocations.

createWeight

Weight stores state associated with a query and IndexSearcher. Count includes the number of createWeight invocations.

The time spent in this area is related to the structure of the query, and is not based on the number of results that are iterated through and scored.

For example:

"context" : {
"millisElapsed" : NumberDouble(4.934751),
"invocationCounts" : {
"createWeight" : NumberLong(1),
"createScorer" : NumberLong(10)
}
}

match

Statistics related to iterating over and matching result documents. This statistic shows the time it takes to determine which document is the next match. Time spent matching results can vary significantly depending on the nature of the query. There are two tasks whose invocation counts are enumerated in this area:

nextDoc

Requests to advance to the next document of the result set. This involves identifying and moving past skips, or other tasks necessary to find the next match. Count includes the number of nextDoc and advance invocations.

refineRoughMatch

Performs a more thorough match. Some queries execute in a two-phase process where a document is first "roughly" matched, and is checked with a second, more thorough phase only after satisfying the first rough match. The refineRoughMatch task is the second phase of the two-phase process. Count includes the number of refineRoughMatch invocations.

For example:

"match" : {
"millisElapsed" : NumberDouble(4.901597),
"invocationCounts" : {
"nextDoc" : NumberLong(541),
"refineRoughMatch" : NumberLong(0)
}
}

score

Statistics related to scoring documents in the result set. There are two tasks whose invocation counts are enumerated in this area:

score

Scores each document in the result set. Count includes the number of score invocations.

setMinCompetitiveScore

Ignores documents whose score is less than the given value. Indicates that a query may have been able to reduce the number of scoring operations performed by ignoring documents with scores below some uncompetitive threshold. Count includes the number of setMinCompetitiveScore invocations.

For example:

"score" : {
"millisElapsed" : NumberDouble(3.931312),
"invocationCounts" : {
"score" : NumberLong(536),
"setMinCompetitiveScore" : NumberLong(0)
}
}

The resultMaterialization document shows the amount of time mongot takes to accomplish the following:

  1. Retrieve result data stored in Lucene in the form of either _id or storedSource.

  2. Serialize the data into BSON format before sending it to mongod.

To learn more, see stats.

The resourceUsage document shows the resource used for running the query. It contains the following fields:

Field
Type
Necessity
Purpose

majorFaults

Long

Required

Number of major page faults, which occur when the system can't find the required data in memory resulting in reading from the backing store such as disk, during query execution.

minorFaults

Long

Required

Number of minor page faults, which occur when the data is in the page cache, but hasn't yet been mapped to the process' page table.

userTimeMs

Long

Required

Amount of CPU time, in milliseconds, spent in user space.

systemTimeMs

Long

Required

Amount of CPU time, in milliseconds, spent in system space.

maxReportingThreads

Integer

Required

Maximum number of threads that mongot used during query execution across all batches. For non-concurrent explain queries, the value is 1.

numBatches

Integer

Required

Total number of batches that mongot was requested when processing the query.

The following examples use the movies collection in the sample_mflix database.

Tip

If you've already loaded the sample dataset, follow the Get Started with Atlas Search tutorial to create an index definition and run Atlas Search queries.

The following example uses different operators to query the title field with the allPlansExecution verbosity mode.

db.movies.explain("allPlansExecution").aggregate([
{
$search: {
"text": {
"path": "title",
"query": "yark",
"fuzzy": {
"maxEdits": 1,
"maxExpansions": 100,
}
}
}
}
])
1{
2 explainVersion: '1',
3 stages: [
4 {
5 '$_internalSearchMongotRemote': {
6 mongotQuery: {
7 text: {
8 path: 'title',
9 query: 'yark',
10 fuzzy: { maxEdits: 1, maxExpansions: 100 }
11 }
12 },
13 explain: {
14 query: {
15 type: 'BooleanQuery',
16 args: {
17 must: [],
18 mustNot: [],
19 should: [
20 {
21 type: 'BoostQuery',
22 args: {
23 query: {
24 type: 'TermQuery',
25 args: { path: 'title', value: 'dark' },
26 stats: {
27 context: { millisElapsed: 0 },
28 match: { millisElapsed: 0 },
29 score: { millisElapsed: 0 }
30 }
31 },
32 boost: 0.75
33 },
34 stats: {
35 context: {
36 millisElapsed: 0.403983,
37 invocationCounts: {
38 createWeight: Long('1'),
39 createScorer: Long('18')
40 }
41 },
42 match: {
43 millisElapsed: 0.094254,
44 invocationCounts: { nextDoc: Long('89') }
45 },
46 score: {
47 millisElapsed: 0.077043,
48 invocationCounts: { score: Long('83') }
49 }
50 }
51 },
52 {
53 type: 'BoostQuery',
54 args: {
55 query: {
56 type: 'TermQuery',
57 args: { path: 'title', value: 'ark' },
58 stats: {
59 context: { millisElapsed: 0 },
60 match: { millisElapsed: 0 },
61 score: { millisElapsed: 0 }
62 }
63 },
64 boost: 0.6666666269302368
65 },
66 stats: {
67 context: {
68 millisElapsed: 0.248528,
69 invocationCounts: {
70 createWeight: Long('1'),
71 createScorer: Long('8')
72 }
73 },
74 match: {
75 millisElapsed: 0.067561,
76 invocationCounts: { nextDoc: Long('3') }
77 },
78 score: {
79 millisElapsed: 0.001649,
80 invocationCounts: { score: Long('2') }
81 }
82 }
83 },
84 {
85 type: 'BoostQuery',
86 args: {
87 query: {
88 type: 'TermQuery',
89 args: { path: 'title', value: 'mark' },
90 stats: {
91 context: { millisElapsed: 0 },
92 match: { millisElapsed: 0 },
93 score: { millisElapsed: 0 }
94 }
95 },
96 boost: 0.75
97 },
98 stats: {
99 context: {
100 millisElapsed: 0.337083,
101 invocationCounts: {
102 createWeight: Long('1'),
103 createScorer: Long('12')
104 }
105 },
106 match: {
107 millisElapsed: 0.006489,
108 invocationCounts: { nextDoc: Long('11') }
109 },
110 score: {
111 millisElapsed: 0.013741,
112 invocationCounts: { score: Long('8') }
113 }
114 }
115 },
116 {
117 type: 'BoostQuery',
118 args: {
119 query: {
120 type: 'TermQuery',
121 args: { path: 'title', value: 'park' },
122 stats: {
123 context: { millisElapsed: 0 },
124 match: { millisElapsed: 0 },
125 score: { millisElapsed: 0 }
126 }
127 },
128 boost: 0.75
129 },
130 stats: {
131 context: {
132 millisElapsed: 0.395528,
133 invocationCounts: {
134 createWeight: Long('1'),
135 createScorer: Long('16')
136 }
137 },
138 match: {
139 millisElapsed: 0.091681,
140 invocationCounts: { nextDoc: Long('32') }
141 },
142 score: {
143 millisElapsed: 0.137827,
144 invocationCounts: { score: Long('27') }
145 }
146 }
147 },
148 {
149 type: 'BoostQuery',
150 args: {
151 query: {
152 type: 'TermQuery',
153 args: { path: 'title', value: 'york' },
154 stats: {
155 context: { millisElapsed: 0 },
156 match: { millisElapsed: 0 },
157 score: { millisElapsed: 0 }
158 }
159 },
160 boost: 0.75
161 },
162 stats: {
163 context: {
164 millisElapsed: 0.150681,
165 invocationCounts: {
166 createWeight: Long('1'),
167 createScorer: Long('16')
168 }
169 },
170 match: {
171 millisElapsed: 0.067298,
172 invocationCounts: { nextDoc: Long('33') }
173 },
174 score: {
175 millisElapsed: 0.038636,
176 invocationCounts: { score: Long('28') }
177 }
178 }
179 },
180 {
181 type: 'BoostQuery',
182 args: {
183 query: {
184 type: 'TermQuery',
185 args: { path: 'title', value: 'yard' },
186 stats: {
187 context: { millisElapsed: 0 },
188 match: { millisElapsed: 0 },
189 score: { millisElapsed: 0 }
190 }
191 },
192 boost: 0.75
193 },
194 stats: {
195 context: {
196 millisElapsed: 0.104308,
197 invocationCounts: {
198 createWeight: Long('1'),
199 createScorer: Long('8')
200 }
201 },
202 match: {
203 millisElapsed: 0.002445,
204 invocationCounts: { nextDoc: Long('4') }
205 },
206 score: {
207 millisElapsed: 0.00233,
208 invocationCounts: { score: Long('3') }
209 }
210 }
211 }
212 ],
213 filter: [],
214 minimumShouldMatch: 0
215 },
216 stats: {
217 context: {
218 millisElapsed: 12.8127,
219 invocationCounts: { createWeight: Long('1'), createScorer: Long('12') }
220 },
221 match: {
222 millisElapsed: 0.761076,
223 invocationCounts: { nextDoc: Long('157') }
224 },
225 score: {
226 millisElapsed: 0.857125,
227 invocationCounts: { score: Long('151') }
228 }
229 }
230 },
231 collectors: {
232 allCollectorStats: {
233 millisElapsed: 2.061296,
234 invocationCounts: {
235 collect: Long('151'),
236 competitiveIterator: Long('6'),
237 setScorer: Long('6')
238 }
239 },
240 facet: { collectorStats: { millisElapsed: 0 } }
241 },
242 resultMaterialization: {
243 stats: {
244 millisElapsed: 17.759502,
245 invocationCounts: { retrieveAndSerialize: Long('1') }
246 }
247 },
248 metadata: {
249 mongotVersion: '1.43.1',
250 mongotHostName: '<hostname>.mongodb.net',
251 indexName: 'default',
252 totalLuceneDocs: 21349
253 },
254 resourceUsage: {
255 majorFaults: Long('0'),
256 minorFaults: Long('98'),
257 userTimeMs: Long('30'),
258 systemTimeMs: Long('0'),
259 maxReportingThreads: 1,
260 numBatches: 1
261 }
262 },
263 requiresSearchMetaCursor: true
264 },
265 nReturned: Long('0'),
266 executionTimeMillisEstimate: Long('108')
267 },
268 {
269 '$_internalSearchIdLookup': {},
270 nReturned: Long('0'),
271 executionTimeMillisEstimate: Long('108')
272 }
273 ],
274 queryShapeHash: '6FD3791F785FA329D4ECD1171E0E5AF6772C18F5F0A7A50FC416D080A93C8CB7',
275 serverInfo: {
276 host: '<hostname>.mongodb.net',
277 port: 27017,
278 version: '8.0.4',
279 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9'
280 },
281 serverParameters: {
282 ...
283 },
284 command: {
285 aggregate: 'movies',
286 pipeline: [
287 {
288 '$search': {
289 text: {
290 path: 'title',
291 query: 'yark',
292 fuzzy: { maxEdits: 1, maxExpansions: 100 }
293 }
294 }
295 }
296 ],
297 cursor: {},
298 '$db': 'sample_mflix'
299 },
300 ok: 1,
301 '$clusterTime': {
302 clusterTime: Timestamp({ t: 1738081279, i: 12 }),
303 signature: {
304 hash: Binary.createFromBase64('DM3imkEw1qT23M2n/b/JibqB1Fg=', 0),
305 keyId: Long('7462787091647168517')
306 }
307 },
308 operationTime: Timestamp({ t: 1738081279, i: 12 })
309}
db.movies.explain("allPlansExecution").aggregate([
{
$search: {
"text": {
"path": "title",
"query": "prince"
},
"highlight": {
"path": "title",
"maxNumPassages": 1,
"maxCharsToExamine": 40
}
}
},
{
$project: {
"description": 1,
"_id": 0,
"highlights": { "$meta": "searchHighlights" }
}
}
])
1{
2 explainVersion: '1',
3 stages: [
4 {
5 '$_internalSearchMongotRemote': {
6 mongotQuery: {
7 text: { path: 'title', query: 'prince' },
8 highlight: { path: 'title', maxNumPassages: 1, maxCharsToExamine: 40 }
9 },
10 explain: {
11 query: {
12 type: 'TermQuery',
13 args: { path: 'title', value: 'prince' },
14 stats: {
15 context: {
16 millisElapsed: 1.034149,
17 invocationCounts: { createWeight: Long('1'), createScorer: Long('10') }
18 },
19 match: {
20 millisElapsed: 0.050591,
21 invocationCounts: { nextDoc: Long('29') }
22 },
23 score: {
24 millisElapsed: 0.027259,
25 invocationCounts: { score: Long('25') }
26 }
27 }
28 },
29 collectors: {
30 allCollectorStats: {
31 millisElapsed: 0.112751,
32 invocationCounts: {
33 collect: Long('25'),
34 competitiveIterator: Long('4'),
35 setScorer: Long('4')
36 }
37 },
38 facet: { collectorStats: { millisElapsed: 0 } }
39 },
40 highlight: {
41 resolvedHighlightPaths: [ '$type:string/title' ],
42 stats: {
43 millisElapsed: 10.665238,
44 invocationCounts: {
45 executeHighlight: Long('1'),
46 setupHighlight: Long('1')
47 }
48 }
49 },
50 resultMaterialization: {
51 stats: {
52 millisElapsed: 3.548075,
53 invocationCounts: { retrieveAndSerialize: Long('1') }
54 }
55 },
56 metadata: {
57 mongotVersion: '1.43.1',
58 mongotHostName: '<hostname>.mongodb.net',
59 indexName: 'default',
60 totalLuceneDocs: 21349
61 },
62 resourceUsage: {
63 majorFaults: Long('0'),
64 minorFaults: Long('0'),
65 userTimeMs: Long('10'),
66 systemTimeMs: Long('0'),
67 maxReportingThreads: 1,
68 numBatches: 1
69 }
70 },
71 requiresSearchMetaCursor: true
72 },
73 nReturned: Long('0'),
74 executionTimeMillisEstimate: Long('31')
75 },
76 {
77 '$_internalSearchIdLookup': {},
78 nReturned: Long('0'),
79 executionTimeMillisEstimate: Long('31')
80 },
81 {
82 '$project': {
83 description: true,
84 highlights: { '$meta': 'searchHighlights' },
85 _id: false
86 },
87 nReturned: Long('0'),
88 executionTimeMillisEstimate: Long('31')
89 }
90 ],
91 queryShapeHash: 'D08444272924C1E04A6E99D0CD4BF82FD929893862B3356F79EC18BBD1F0EF0C',
92 serverInfo: {
93 host: '<hostname>.mongodb.net',
94 port: 27017,
95 version: '8.0.4',
96 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9'
97 },
98 serverParameters: {
99 internalQueryFacetBufferSizeBytes: 104857600,
100 internalQueryFacetMaxOutputDocSizeBytes: 104857600,
101 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
102 internalDocumentSourceGroupMaxMemoryBytes: 104857600,
103 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
104 internalQueryProhibitBlockingMergeOnMongoS: 0,
105 internalQueryMaxAddToSetBytes: 104857600,
106 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
107 internalQueryFrameworkControl: 'trySbeRestricted',
108 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
109 },
110 command: {
111 aggregate: 'movies',
112 pipeline: [
113 {
114 '$search': {
115 text: { path: 'title', query: 'prince' },
116 highlight: { path: 'title', maxNumPassages: 1, maxCharsToExamine: 40 }
117 }
118 },
119 {
120 '$project': {
121 description: 1,
122 _id: 0,
123 highlights: { '$meta': 'searchHighlights' }
124 }
125 }
126 ],
127 cursor: {},
128 '$db': 'sample_mflix'
129 },
130 ok: 1,
131 '$clusterTime': {
132 clusterTime: Timestamp({ t: 1738081637, i: 1 }),
133 signature: {
134 hash: Binary.createFromBase64('TnFwebZsmrjLunk7/TN+9rfJ/8Y=', 0),
135 keyId: Long('7462787091647168517')
136 }
137 },
138 operationTime: Timestamp({ t: 1738081637, i: 1 })
139}
db.movies.explain("allPlansExecution").aggregate([
{
"$searchMeta": {
"facet": {
"operator": {
"near": {
"path": "released",
"origin": ISODate("1921-11-01T00:00:00.000+00:00"),
"pivot": 7776000000
}
},
"facets": {
"genresFacet": {
"type": "string",
"path": "genres"
},
"yearFacet" : {
"type" : "number",
"path" : "year",
"boundaries" : [1910,1920,1930,1940]
}
}
}
}
}
])
1{
2 explainVersion: '1',
3 stages: [
4 {
5 '$searchMeta': {
6 mongotQuery: {
7 facet: {
8 operator: {
9 near: {
10 path: 'released',
11 origin: ISODate('1921-11-01T00:00:00.000Z'),
12 pivot: 7776000000
13 }
14 },
15 facets: {
16 genresFacet: { type: 'string', path: 'genres' },
17 yearFacet: {
18 type: 'number',
19 path: 'year',
20 boundaries: [ 1910, 1920, 1930, 1940 ]
21 }
22 }
23 }
24 },
25 explain: {
26 query: {
27 type: 'LongDistanceFeatureQuery',
28 args: {},
29 stats: {
30 context: {
31 millisElapsed: 0.684076,
32 invocationCounts: { createWeight: Long('1'), createScorer: Long('12') }
33 },
34 match: {
35 millisElapsed: 1.285512,
36 invocationCounts: { nextDoc: Long('20884') }
37 },
38 score: {
39 millisElapsed: 1.321738,
40 invocationCounts: { score: Long('20878') }
41 }
42 }
43 },
44 collectors: {
45 allCollectorStats: {
46 millisElapsed: 10.536043,
47 invocationCounts: {
48 collect: Long('20878'),
49 competitiveIterator: Long('6'),
50 setScorer: Long('6')
51 }
52 },
53 facet: {
54 collectorStats: {
55 millisElapsed: 3.730834,
56 invocationCounts: { collect: Long('20878'), setScorer: Long('6') }
57 },
58 createCountsStats: {
59 millisElapsed: 10.350302,
60 invocationCounts: { generateFacetCounts: Long('2') }
61 },
62 stringFacetCardinalities: { genresFacet: { queried: 10, total: 25 } }
63 }
64 },
65 resultMaterialization: {
66 stats: {
67 millisElapsed: 10.645713,
68 invocationCounts: { retrieveAndSerialize: Long('1') }
69 }
70 },
71 metadata: {
72 mongotVersion: '1.43.1',
73 mongotHostName: '<hostname>.mongodb.net',
74 indexName: 'default',
75 totalLuceneDocs: 21349
76 },
77 resourceUsage: {
78 majorFaults: Long('0'),
79 minorFaults: Long('0'),
80 userTimeMs: Long('10'),
81 systemTimeMs: Long('0'),
82 maxReportingThreads: 1,
83 numBatches: 1
84 }
85 },
86 requiresSearchMetaCursor: true
87 },
88 nReturned: Long('0'),
89 executionTimeMillisEstimate: Long('57')
90 }
91 ],
92 queryShapeHash: '582DB864C9BCFB96896CF1A3079CF70FAC10A9A1E19E8D66DF20A2BB40424FB5',
93 serverInfo: {
94 host: '<hostname>.mongodb.net',
95 port: 27017,
96 version: '8.0.4',
97 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9'
98 },
99 serverParameters: {
100 internalQueryFacetBufferSizeBytes: 104857600,
101 internalQueryFacetMaxOutputDocSizeBytes: 104857600,
102 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
103 internalDocumentSourceGroupMaxMemoryBytes: 104857600,
104 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
105 internalQueryProhibitBlockingMergeOnMongoS: 0,
106 internalQueryMaxAddToSetBytes: 104857600,
107 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
108 internalQueryFrameworkControl: 'trySbeRestricted',
109 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
110 },
111 command: {
112 aggregate: 'movies',
113 pipeline: [
114 {
115 '$searchMeta': {
116 facet: {
117 operator: {
118 near: {
119 path: 'released',
120 origin: ISODate('1921-11-01T00:00:00.000Z'),
121 pivot: 7776000000
122 }
123 },
124 facets: {
125 genresFacet: { type: 'string', path: 'genres' },
126 yearFacet: {
127 type: 'number',
128 path: 'year',
129 boundaries: [ 1910, 1920, 1930, 1940 ]
130 }
131 }
132 }
133 }
134 }
135 ],
136 cursor: {},
137 '$db': 'sample_mflix'
138 },
139 ok: 1,
140 '$clusterTime': {
141 clusterTime: Timestamp({ t: 1738081767, i: 1 }),
142 signature: {
143 hash: Binary.createFromBase64('ieRjqe84DdOnmlCcP3XBelo8vyM=', 0),
144 keyId: Long('7462787091647168517')
145 }
146 },
147 operationTime: Timestamp({ t: 1738081767, i: 1 })
148}
db.movies.explain("allPlansExecution").aggregate([
{
$search: {
"text": {
"path": "title",
"query": "yark",
"fuzzy": {
"maxEdits": 1,
"maxExpansions": 100,
}
}
}
}
])
1{
2 explainVersion: '1',
3 stages: [
4 {
5 '$_internalSearchMongotRemote': {
6 mongotQuery: {
7 text: {
8 path: 'title',
9 query: 'yark',
10 fuzzy: { maxEdits: 1, maxExpansions: 100 }
11 }
12 },
13 explain: {
14 metadata: {
15 mongotVersion: '1.43.2',
16 mongotHostName: '<hostname>.mongodb.net',
17 indexName: 'default'
18 },
19 resourceUsage: {
20 majorFaults: Long('0'),
21 minorFaults: Long('90'),
22 userTimeMs: Long('20'),
23 systemTimeMs: Long('0'),
24 maxReportingThreads: 1,
25 numBatches: 1
26 },
27 indexPartitionExplain: [
28 {
29 query: {
30 type: 'BooleanQuery',
31 args: {
32 must: [],
33 mustNot: [],
34 should: [
35 {
36 type: 'BoostQuery',
37 args: {
38 query: {
39 type: 'TermQuery',
40 args: { path: 'title', value: 'dark' },
41 stats: {
42 context: { millisElapsed: 0 },
43 match: { millisElapsed: 0 },
44 score: { millisElapsed: 0 }
45 }
46 },
47 boost: 0.75
48 },
49 stats: {
50 context: {
51 millisElapsed: 0.035132,
52 invocationCounts: {
53 createWeight: Long('1'),
54 createScorer: Long('3')
55 }
56 },
57 match: {
58 millisElapsed: 0.067392,
59 invocationCounts: { nextDoc: Long('50') }
60 },
61 score: {
62 millisElapsed: 0.032873,
63 invocationCounts: { score: Long('49') }
64 }
65 }
66 },
67 {
68 type: 'BoostQuery',
69 args: {
70 query: {
71 type: 'TermQuery',
72 args: { path: 'title', value: 'park' },
73 stats: {
74 context: { millisElapsed: 0 },
75 match: { millisElapsed: 0 },
76 score: { millisElapsed: 0 }
77 }
78 },
79 boost: 0.75
80 },
81 stats: {
82 context: {
83 millisElapsed: 0.025347,
84 invocationCounts: {
85 createWeight: Long('1'),
86 createScorer: Long('3')
87 }
88 },
89 match: {
90 millisElapsed: 0.012782,
91 invocationCounts: { nextDoc: Long('16') }
92 },
93 score: {
94 millisElapsed: 0.007131,
95 invocationCounts: { score: Long('15') }
96 }
97 }
98 },
99 {
100 type: 'BoostQuery',
101 args: {
102 query: {
103 type: 'TermQuery',
104 args: { path: 'title', value: 'mark' },
105 stats: {
106 context: { millisElapsed: 0 },
107 match: { millisElapsed: 0 },
108 score: { millisElapsed: 0 }
109 }
110 },
111 boost: 0.75
112 },
113 stats: {
114 context: {
115 millisElapsed: 0.028604,
116 invocationCounts: {
117 createWeight: Long('1'),
118 createScorer: Long('3')
119 }
120 },
121 match: {
122 millisElapsed: 0.001842,
123 invocationCounts: { nextDoc: Long('4') }
124 },
125 score: {
126 millisElapsed: 0.001571,
127 invocationCounts: { score: Long('3') }
128 }
129 }
130 },
131 {
132 type: 'BoostQuery',
133 args: {
134 query: {
135 type: 'TermQuery',
136 args: { path: 'title', value: 'yard' },
137 stats: {
138 context: { millisElapsed: 0 },
139 match: { millisElapsed: 0 },
140 score: { millisElapsed: 0 }
141 }
142 },
143 boost: 0.75
144 },
145 stats: {
146 context: {
147 millisElapsed: 0.02443,
148 invocationCounts: {
149 createWeight: Long('1'),
150 createScorer: Long('3')
151 }
152 },
153 match: {
154 millisElapsed: 0.001531,
155 invocationCounts: { nextDoc: Long('3') }
156 },
157 score: {
158 millisElapsed: 0.001065,
159 invocationCounts: { score: Long('2') }
160 }
161 }
162 },
163 {
164 type: 'BoostQuery',
165 args: {
166 query: {
167 type: 'TermQuery',
168 args: { path: 'title', value: 'ark' },
169 stats: {
170 context: { millisElapsed: 0 },
171 match: { millisElapsed: 0 },
172 score: { millisElapsed: 0 }
173 }
174 },
175 boost: 0.6666666269302368
176 },
177 stats: {
178 context: {
179 millisElapsed: 0.087657,
180 invocationCounts: {
181 createWeight: Long('1'),
182 createScorer: Long('3')
183 }
184 },
185 match: {
186 millisElapsed: 0.001745,
187 invocationCounts: { nextDoc: Long('2') }
188 },
189 score: {
190 millisElapsed: 0.000471,
191 invocationCounts: { score: Long('1') }
192 }
193 }
194 },
195 {
196 type: 'BoostQuery',
197 args: {
198 query: {
199 type: 'TermQuery',
200 args: { path: 'title', value: 'york' },
201 stats: {
202 context: { millisElapsed: 0 },
203 match: { millisElapsed: 0 },
204 score: { millisElapsed: 0 }
205 }
206 },
207 boost: 0.75
208 },
209 stats: {
210 context: {
211 millisElapsed: 0.024546,
212 invocationCounts: {
213 createWeight: Long('1'),
214 createScorer: Long('3')
215 }
216 },
217 match: {
218 millisElapsed: 0.01154,
219 invocationCounts: { nextDoc: Long('15') }
220 },
221 score: {
222 millisElapsed: 0.006867,
223 invocationCounts: { score: Long('14') }
224 }
225 }
226 }
227 ],
228 filter: [],
229 minimumShouldMatch: 0
230 },
231 stats: {
232 context: {
233 millisElapsed: 0.337917,
234 invocationCounts: {
235 createWeight: Long('1'),
236 createScorer: Long('2')
237 }
238 },
239 match: {
240 millisElapsed: 0.165335,
241 invocationCounts: { nextDoc: Long('85') }
242 },
243 score: {
244 millisElapsed: 0.098247,
245 invocationCounts: { score: Long('84') }
246 }
247 }
248 },
249 collectors: {
250 allCollectorStats: {
251 millisElapsed: 0.205935,
252 invocationCounts: {
253 collect: Long('84'),
254 competitiveIterator: Long('1'),
255 setScorer: Long('1')
256 }
257 },
258 facet: { collectorStats: { millisElapsed: 0 } }
259 },
260 metadata: { totalLuceneDocs: 10635 }
261 },
262 {
263 query: {
264 type: 'BooleanQuery',
265 args: {
266 must: [],
267 mustNot: [],
268 should: [
269 {
270 type: 'BoostQuery',
271 args: {
272 query: {
273 type: 'TermQuery',
274 args: { path: 'title', value: 'dark' },
275 stats: {
276 context: { millisElapsed: 0 },
277 match: { millisElapsed: 0 },
278 score: { millisElapsed: 0 }
279 }
280 },
281 boost: 0.75
282 },
283 stats: {
284 context: {
285 millisElapsed: 0.033805,
286 invocationCounts: {
287 createWeight: Long('1'),
288 createScorer: Long('3')
289 }
290 },
291 match: {
292 millisElapsed: 0.049273,
293 invocationCounts: { nextDoc: Long('35') }
294 },
295 score: {
296 millisElapsed: 0.023509,
297 invocationCounts: { score: Long('34') }
298 }
299 }
300 },
301 {
302 type: 'BoostQuery',
303 args: {
304 query: {
305 type: 'TermQuery',
306 args: { path: 'title', value: 'park' },
307 stats: {
308 context: { millisElapsed: 0 },
309 match: { millisElapsed: 0 },
310 score: { millisElapsed: 0 }
311 }
312 },
313 boost: 0.75
314 },
315 stats: {
316 context: {
317 millisElapsed: 0.025853,
318 invocationCounts: {
319 createWeight: Long('1'),
320 createScorer: Long('3')
321 }
322 },
323 match: {
324 millisElapsed: 0.016276,
325 invocationCounts: { nextDoc: Long('13') }
326 },
327 score: {
328 millisElapsed: 0.007533,
329 invocationCounts: { score: Long('12') }
330 }
331 }
332 },
333 {
334 type: 'BoostQuery',
335 args: {
336 query: {
337 type: 'TermQuery',
338 args: { path: 'title', value: 'mark' },
339 stats: {
340 context: { millisElapsed: 0 },
341 match: { millisElapsed: 0 },
342 score: { millisElapsed: 0 }
343 }
344 },
345 boost: 0.75
346 },
347 stats: {
348 context: {
349 millisElapsed: 0.027083,
350 invocationCounts: {
351 createWeight: Long('1'),
352 createScorer: Long('3')
353 }
354 },
355 match: {
356 millisElapsed: 0.006663,
357 invocationCounts: { nextDoc: Long('6') }
358 },
359 score: {
360 millisElapsed: 0.002944,
361 invocationCounts: { score: Long('5') }
362 }
363 }
364 },
365 {
366 type: 'BoostQuery',
367 args: {
368 query: {
369 type: 'TermQuery',
370 args: { path: 'title', value: 'yard' },
371 stats: {
372 context: { millisElapsed: 0 },
373 match: { millisElapsed: 0 },
374 score: { millisElapsed: 0 }
375 }
376 },
377 boost: 0.75
378 },
379 stats: {
380 context: {
381 millisElapsed: 0.025523,
382 invocationCounts: {
383 createWeight: Long('1'),
384 createScorer: Long('3')
385 }
386 },
387 match: {
388 millisElapsed: 0.000945,
389 invocationCounts: { nextDoc: Long('2') }
390 },
391 score: {
392 millisElapsed: 0.000558,
393 invocationCounts: { score: Long('1') }
394 }
395 }
396 },
397 {
398 type: 'BoostQuery',
399 args: {
400 query: {
401 type: 'TermQuery',
402 args: { path: 'title', value: 'ark' },
403 stats: {
404 context: { millisElapsed: 0 },
405 match: { millisElapsed: 0 },
406 score: { millisElapsed: 0 }
407 }
408 },
409 boost: 0.6666666269302368
410 },
411 stats: {
412 context: {
413 millisElapsed: 0.069448,
414 invocationCounts: {
415 createWeight: Long('1'),
416 createScorer: Long('3')
417 }
418 },
419 match: {
420 millisElapsed: 0.001375,
421 invocationCounts: { nextDoc: Long('2') }
422 },
423 score: {
424 millisElapsed: 0.000477,
425 invocationCounts: { score: Long('1') }
426 }
427 }
428 },
429 {
430 type: 'BoostQuery',
431 args: {
432 query: {
433 type: 'TermQuery',
434 args: { path: 'title', value: 'york' },
435 stats: {
436 context: { millisElapsed: 0 },
437 match: { millisElapsed: 0 },
438 score: { millisElapsed: 0 }
439 }
440 },
441 boost: 0.75
442 },
443 stats: {
444 context: {
445 millisElapsed: 0.025056,
446 invocationCounts: {
447 createWeight: Long('1'),
448 createScorer: Long('3')
449 }
450 },
451 match: {
452 millisElapsed: 0.013107,
453 invocationCounts: { nextDoc: Long('15') }
454 },
455 score: {
456 millisElapsed: 0.007251,
457 invocationCounts: { score: Long('14') }
458 }
459 }
460 }
461 ],
462 filter: [],
463 minimumShouldMatch: 0
464 },
465 stats: {
466 context: {
467 millisElapsed: 0.292379,
468 invocationCounts: {
469 createWeight: Long('1'),
470 createScorer: Long('2')
471 }
472 },
473 match: {
474 millisElapsed: 0.14967,
475 invocationCounts: { nextDoc: Long('68') }
476 },
477 score: {
478 millisElapsed: 0.082494,
479 invocationCounts: { score: Long('67') }
480 }
481 }
482 },
483 collectors: {
484 allCollectorStats: {
485 millisElapsed: 0.159291,
486 invocationCounts: {
487 collect: Long('67'),
488 competitiveIterator: Long('1'),
489 setScorer: Long('1')
490 }
491 },
492 facet: { collectorStats: { millisElapsed: 0 } }
493 },
494 metadata: { totalLuceneDocs: 10714 }
495 }
496 ]
497 },
498 requiresSearchMetaCursor: true
499 },
500 nReturned: Long('0'),
501 executionTimeMillisEstimate: Long('59')
502 },
503 {
504 '$_internalSearchIdLookup': {},
505 nReturned: Long('0'),
506 executionTimeMillisEstimate: Long('59')
507 }
508 ],
509 queryShapeHash: '6FD3791F785FA329D4ECD1171E0E5AF6772C18F5F0A7A50FC416D080A93C8CB7',
510 serverInfo: {
511 host: '<hostname>.mongodb.net',
512 port: 27017,
513 version: '8.0.4',
514 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9'
515 },
516 serverParameters: {
517 internalQueryFacetBufferSizeBytes: 104857600,
518 internalQueryFacetMaxOutputDocSizeBytes: 104857600,
519 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
520 internalDocumentSourceGroupMaxMemoryBytes: 104857600,
521 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
522 internalQueryProhibitBlockingMergeOnMongoS: 0,
523 internalQueryMaxAddToSetBytes: 104857600,
524 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
525 internalQueryFrameworkControl: 'trySbeRestricted',
526 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
527 },
528 command: {
529 aggregate: 'movies',
530 pipeline: [
531 {
532 '$search': {
533 text: {
534 path: 'title',
535 query: 'yark',
536 fuzzy: { maxEdits: 1, maxExpansions: 100 }
537 }
538 }
539 }
540 ],
541 cursor: {},
542 '$db': 'sample_mflix'
543 },
544 ok: 1,
545 '$clusterTime': {
546 clusterTime: Timestamp({ t: 1739918308, i: 1 }),
547 signature: {
548 hash: Binary.createFromBase64('D0UjelHYrLf3bfSMxrfVbgVtcIw=', 0),
549 keyId: Long('7470183785540091909')
550 }
551 },
552 operationTime: Timestamp({ t: 1739918308, i: 1 })
553}

The following example uses different operators to query the title field with the queryPlanner verbosity mode.

db.movies.explain("queryPlanner").aggregate([
{
$search: {
"text": {
"path": "title",
"query": "yark",
"fuzzy": {
"maxEdits": 1,
"maxExpansions": 100,
}
}
}
}
])
1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "text" : {
7 "path" : "title",
8 "query" : "yark",
9 "fuzzy" : {
10 "maxEdits" : 1,
11 "maxExpansions" : 100
12 }
13 }
14 },
15 "explain" : {
16 "type" : "BooleanQuery",
17 "args" : {
18 "must" : [ ],
19 "mustNot" : [ ],
20 "should" : [
21 {
22 "type" : "BoostQuery",
23 "args" : {
24 "query" : {
25 "type" : "TermQuery",
26 "args" : {
27 "path" : "title",
28 "value" : "ark"
29 }
30 },
31 "boost" : 0.6666666269302368
32 }
33 },
34 {
35 "type" : "BoostQuery",
36 "args" : {
37 "query" : {
38 "type" : "TermQuery",
39 "args" : {
40 "path" : "title",
41 "value" : "yard"
42 }
43 },
44 "boost" : 0.75
45 }
46 },
47 {
48 "type" : "BoostQuery",
49 "args" : {
50 "query" : {
51 "type" : "TermQuery",
52 "args" : {
53 "path" : "title",
54 "value" : "mark"
55 }
56 },
57 "boost" : 0.75
58 }
59 },
60 {
61 "type" : "BoostQuery",
62 "args" : {
63 "query" : {
64 "type" : "TermQuery",
65 "args" : {
66 "path" : "title",
67 "value" : "park"
68 }
69 },
70 "boost" : 0.75
71 }
72 },
73 {
74 "type" : "BoostQuery",
75 "args" : {
76 "query" : {
77 "type" : "TermQuery",
78 "args" : {
79 "path" : "title",
80 "value" : "dark"
81 }
82 },
83 "boost" : 0.75
84 }
85 },
86 {
87 "type" : "BoostQuery",
88 "args" : {
89 "query" : {
90 "type" : "TermQuery",
91 "args" : {
92 "path" : "title",
93 "value" : "york"
94 }
95 },
96 "boost" : 0.75
97 }
98 }
99 ],
100 "filter" : [ ],
101 "minimumShouldMatch" : 0
102 }
103 }
104 }
105 },
106 {
107 "$_internalSearchIdLookup" : { }
108 }
109 ],
110 "serverInfo" : {
111 "host" : "<hostname>.mongodb.net",
112 "port" : 27017,
113 "version" : "4.4.3",
114 "gitVersion" : "913d6b62acfbb344dde1b116f4161360acd8fd13"
115 },
116 "ok" : 1,
117 "$clusterTime" : {
118 "clusterTime" : Timestamp(1612457287, 1),
119 "signature" : {
120 "hash" : BinData(0,"kzn7hY7NOduVIqcfx+40ENKbMKQ="),
121 "keyId" : NumberLong("1234567890123456789")
122 }
123 },
124 "operationTime" : Timestamp(1612457287, 1)
125}
db.movies.explain("queryPlanner").aggregate([
{
$search: {
"text": {
"path": "title",
"query": "prince"
},
"highlight": {
"path": "title",
"maxNumPassages": 1,
"maxCharsToExamine": 40
}
}
},
{
$project: {
"description": 1,
"_id": 0,
"highlights": { "$meta": "searchHighlights" }
}
}
])
1{
2 explainVersion: '1',
3 stages: [
4 {
5 '$_internalSearchMongotRemote': {
6 mongotQuery: {
7 text: { path: 'title', query: 'prince' },
8 highlight: { path: 'title', maxNumPassages: 1, maxCharsToExamine: 40 }
9 },
10 explain: {
11 query: {
12 type: 'TermQuery',
13 args: { path: 'title', value: 'prince' }
14 },
15 highlight: { resolvedHighlightPaths: [ '$type:string/title' ] },
16 metadata: {
17 mongotVersion: '1.43.1',
18 mongotHostName: '<hostname>.mongodb.net',
19 indexName: 'default',
20 totalLuceneDocs: 21349
21 }
22 },
23 requiresSearchMetaCursor: true
24 }
25 },
26 { '$_internalSearchIdLookup': {} },
27 {
28 '$project': {
29 description: true,
30 highlights: { '$meta': 'searchHighlights' },
31 _id: false
32 }
33 }
34 ],
35 queryShapeHash: 'D08444272924C1E04A6E99D0CD4BF82FD929893862B3356F79EC18BBD1F0EF0C',
36 serverInfo: {
37 host: '<hostname>.mongodb.net',
38 port: 27017,
39 version: '8.0.4',
40 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9'
41 },
42 serverParameters: {
43 internalQueryFacetBufferSizeBytes: 104857600,
44 internalQueryFacetMaxOutputDocSizeBytes: 104857600,
45 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
46 internalDocumentSourceGroupMaxMemoryBytes: 104857600,
47 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
48 internalQueryProhibitBlockingMergeOnMongoS: 0,
49 internalQueryMaxAddToSetBytes: 104857600,
50 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
51 internalQueryFrameworkControl: 'trySbeRestricted',
52 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
53 },
54 command: {
55 aggregate: 'movies',
56 pipeline: [
57 {
58 '$search': {
59 text: { path: 'title', query: 'prince' },
60 highlight: { path: 'title', maxNumPassages: 1, maxCharsToExamine: 40 }
61 }
62 },
63 {
64 '$project': {
65 description: 1,
66 _id: 0,
67 highlights: { '$meta': 'searchHighlights' }
68 }
69 }
70 ],
71 cursor: {},
72 '$db': 'sample_mflix'
73 },
74 ok: 1,
75 '$clusterTime': {
76 clusterTime: Timestamp({ t: 1738080637, i: 1 }),
77 signature: {
78 hash: Binary.createFromBase64('fIedxkRaoE5IWmIaN7/BsRC0AJc=', 0),
79 keyId: Long('7462787091647168517')
80 }
81 },
82 operationTime: Timestamp({ t: 1738080637, i: 1 })
83}
db.movies.explain("queryPlanner").aggregate([
{
"$searchMeta": {
"facet": {
"operator": {
"near": {
"path": "released",
"origin": ISODate("1921-11-01T00:00:00.000+00:00"),
"pivot": 7776000000
}
},
"facets": {
"genresFacet": {
"type": "string",
"path": "genres"
},
"yearFacet" : {
"type" : "number",
"path" : "year",
"boundaries" : [1910,1920,1930,1940]
}
}
}
}
}
])
1{
2 explainVersion: '1',
3 stages: [
4 {
5 '$searchMeta': {
6 mongotQuery: {
7 facet: {
8 operator: {
9 near: {
10 path: 'released',
11 origin: ISODate('1921-11-01T00:00:00.000Z'),
12 pivot: 7776000000
13 }
14 },
15 facets: {
16 genresFacet: { type: 'string', path: 'genres' },
17 yearFacet: {
18 type: 'number',
19 path: 'year',
20 boundaries: [ 1910, 1920, 1930, 1940 ]
21 }
22 }
23 }
24 },
25 explain: {
26 query: { type: 'LongDistanceFeatureQuery', args: {} },
27 collectors: {
28 facet: {
29 stringFacetCardinalities: { genresFacet: { queried: 10, total: 25 } }
30 }
31 },
32 metadata: {
33 mongotVersion: '1.43.1',
34 mongotHostName: '<hostname>.mongodb.net',
35 indexName: 'default',
36 totalLuceneDocs: 21349
37 }
38 },
39 requiresSearchMetaCursor: true
40 }
41 }
42 ],
43 queryShapeHash: '582DB864C9BCFB96896CF1A3079CF70FAC10A9A1E19E8D66DF20A2BB40424FB5',
44 serverInfo: {
45 host: '<hostname>.mongodb.net',
46 port: 27017,
47 version: '8.0.4',
48 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9'
49 },
50 serverParameters: {
51 internalQueryFacetBufferSizeBytes: 104857600,
52 internalQueryFacetMaxOutputDocSizeBytes: 104857600,
53 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
54 internalDocumentSourceGroupMaxMemoryBytes: 104857600,
55 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
56 internalQueryProhibitBlockingMergeOnMongoS: 0,
57 internalQueryMaxAddToSetBytes: 104857600,
58 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
59 internalQueryFrameworkControl: 'trySbeRestricted',
60 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
61 },
62 command: {
63 aggregate: 'movies',
64 pipeline: [
65 {
66 '$searchMeta': {
67 facet: {
68 operator: {
69 near: {
70 path: 'released',
71 origin: ISODate('1921-11-01T00:00:00.000Z'),
72 pivot: 7776000000
73 }
74 },
75 facets: {
76 genresFacet: { type: 'string', path: 'genres' },
77 yearFacet: {
78 type: 'number',
79 path: 'year',
80 boundaries: [ 1910, 1920, 1930, 1940 ]
81 }
82 }
83 }
84 }
85 }
86 ],
87 cursor: {},
88 '$db': 'sample_mflix'
89 },
90 ok: 1,
91 '$clusterTime': {
92 clusterTime: Timestamp({ t: 1738080797, i: 1 }),
93 signature: {
94 hash: Binary.createFromBase64('2E8qAEihttRWdJRyCTXRfA1es7I=', 0),
95 keyId: Long('7462787091647168517')
96 }
97 },
98 operationTime: Timestamp({ t: 1738080797, i: 1 })
99}

For queries that specify a $limit stage in the pipeline, the explain results include the mongotDocsRequested metric, which shows the number of documents that mongod requested from mongot.

Example

{
"mongotQuery": {},
"explain": {},
"limit": <int>,
"sortSpec": {},
"mongotDocsRequested": <int>,
}

The following example uses the autocomplete operator to query the title field with the executionStats verbosity mode.

1db.movies.explain("executionStats").aggregate([
2 {
3 "$search": {
4 "autocomplete": {
5 "path": "title",
6 "query": "pre",
7 "fuzzy": {
8 "maxEdits": 1,
9 "prefixLength": 1,
10 "maxExpansions": 256
11 }
12 }
13 }
14 }
15])
1{
2 explainVersion: '1',
3 stages: [
4 {
5 '$_internalSearchMongotRemote': {
6 mongotQuery: {
7 autocomplete: {
8 path: 'title',
9 query: 'pre',
10 fuzzy: { maxEdits: 1, prefixLength: 1, maxExpansions: 256 }
11 }
12 },
13 explain: {
14 query: {
15 type: 'BooleanQuery',
16 args: {
17 must: [
18 {
19 type: 'MultiTermQueryConstantScoreBlendedWrapper',
20 args: {
21 queries: [
22 {
23 type: 'DefaultQuery',
24 args: { queryType: 'AutomatonQuery' },
25 stats: {
26 context: { millisElapsed: 0 },
27 match: { millisElapsed: 0 },
28 score: { millisElapsed: 0 }
29 }
30 }
31 ]
32 },
33 stats: {
34 context: {
35 millisElapsed: 34.187255,
36 invocationCounts: {
37 createWeight: Long('1'),
38 createScorer: Long('15')
39 }
40 },
41 match: {
42 millisElapsed: 1.077211,
43 invocationCounts: { nextDoc: Long('812') }
44 },
45 score: {
46 millisElapsed: 0.274761,
47 invocationCounts: { score: Long('807') }
48 }
49 }
50 }
51 ],
52 mustNot: [],
53 should: [
54 {
55 type: 'TermQuery',
56 args: { path: 'title', value: 'pre' },
57 stats: {
58 context: {
59 millisElapsed: 2.495506,
60 invocationCounts: {
61 createWeight: Long('1'),
62 createScorer: Long('5')
63 }
64 },
65 match: { millisElapsed: 0 },
66 score: { millisElapsed: 0 }
67 }
68 }
69 ],
70 filter: [],
71 minimumShouldMatch: 0
72 },
73 stats: {
74 context: {
75 millisElapsed: 43.795864,
76 invocationCounts: { createWeight: Long('1'), createScorer: Long('10') }
77 },
78 match: {
79 millisElapsed: 1.911068,
80 invocationCounts: { nextDoc: Long('812') }
81 },
82 score: {
83 millisElapsed: 0.982801,
84 invocationCounts: { score: Long('807') }
85 }
86 }
87 },
88 collectors: {
89 allCollectorStats: {
90 millisElapsed: 2.51114,
91 invocationCounts: {
92 collect: Long('807'),
93 competitiveIterator: Long('5'),
94 setScorer: Long('5')
95 }
96 },
97 facet: { collectorStats: { millisElapsed: 0 } }
98 },
99 resultMaterialization: {
100 stats: {
101 millisElapsed: 10.23124,
102 invocationCounts: { retrieveAndSerialize: Long('1') }
103 }
104 },
105 metadata: {
106 mongotVersion: '1.43.0',
107 mongotHostName: 'atlas-11decp-shard-00-01.2rnul.mogodb.net',
108 indexName: 'default',
109 totalLuceneDocs: 21349
110 },
111 resourceUsage: {
112 majorFaults: Long('0'),
113 minorFaults: Long('145'),
114 userTimeMs: Long('30'),
115 systemTimeMs: Long('10'),
116 maxReportingThreads: 1,
117 numBatches: 1
118 }
119 },
120 requiresSearchMetaCursor: true
121 },
122 nReturned: Long('0'),
123 executionTimeMillisEstimate: Long('311')
124 },
125 {
126 '$_internalSearchIdLookup': {},
127 nReturned: Long('0'),
128 executionTimeMillisEstimate: Long('311')
129 }
130 ],
131 queryShapeHash: '6FD3791F785FA329D4ECD1171E0E5AF6772C18F5F0A7A50FC416D080A93C8CB7',
132 serverInfo: {
133 host: 'atlas-11decp-shard-00-01.2rnul.mogodb.net',
134 port: 27017,
135 version: '8.0.4',
136 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9'
137 },
138 serverParameters: {
139 internalQueryFacetBufferSizeBytes: 104857600,
140 internalQueryFacetMaxOutputDocSizeBytes: 104857600,
141 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
142 internalDocumentSourceGroupMaxMemoryBytes: 104857600,
143 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
144 internalQueryProhibitBlockingMergeOnMongoS: 0,
145 internalQueryMaxAddToSetBytes: 104857600,
146 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
147 internalQueryFrameworkControl: 'trySbeRestricted',
148 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
149 },
150 command: {
151 aggregate: 'movies',
152 pipeline: [
153 {
154 '$search': {
155 autocomplete: {
156 path: 'title',
157 query: 'pre',
158 fuzzy: { maxEdits: 1, prefixLength: 1, maxExpansions: 256 }
159 }
160 }
161 }
162 ],
163 cursor: {},
164 '$db': 'sample_mflix'
165 },
166 ok: 1,
167 '$clusterTime': {
168 clusterTime: Timestamp({ t: 1737671412, i: 10 }),
169 signature: {
170 hash: Binary.createFromBase64('a3CSqvS0rziAYQCk33WzTo/0Sow=', 0),
171 keyId: Long('7462787091647168517')
172 }
173 },
174 operationTime: Timestamp({ t: 1737671412, i: 10 })
175}

To learn more about the explain response elements, see Explain Results.