Docs Menu
Docs Home
/ /

クエリプランと実行統計を検索する方法

MongoDB Search$search explainクエリは、explain メソッドを有効にしてクエリを実行すると、 クエリプランと実行統計に関する情報を返します。 を使用してクエリを実行すると、 MongoDB Search は、クエリが Lucene の内部で実行された方法を説明する統計とメタデータを含む BSONドキュメントを返します。

Tip

explain コマンド

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

冗長モードは、explain の動作と返される情報の量を制御します。値は、冗長を減らすために、次のいずれかになります。

クエリの実行統計を含む stats フィールドを含むクエリプランに関する情報プラン選択 中にキャプチャされた部分的な実行データが含まれます。

クエリの実行統計情報をもつ stats フィールドを含む、クエリプランに関する情報です。

queryPlanner (デフォルト)

クエリプランに関する情報。stats フィールドは、クエリの実行統計をもつため、含まれていません。

explain メソッドを使用するクエリは、stages.$_internalSearchMongotRemoteオブジェクト内の次のフィールドを返します。

オプション
タイプ
目的

mongotQuery

ドキュメント

実行したクエリが含まれます。

explain

ドキュメント

explainの結果が含まれます。詳しくは、「 Explain 結果 」を参照してください。

internalMongotBatchSizeHistory

整数の配列

mongotmongod に返したドキュメントの各バッチするのサイズが含まれます。

explainメソッドは、 ドキュメント内に次のフィールドを含むBSONドキュメントを返します。explain

オプション
タイプ
必要性
目的

collectors

ドキュメント

任意

コレクターの実行統計を説明します。indexPartitionExplainが存在する場合、これはトップレベルではなく、各indexPartitionExplainの中にネストされます。

highlight

ドキュメント

任意

クエリのハイライト実行に関する詳細情報。これは、クエリでハイライトを指定した場合にのみ返されます。

indexPartitionExplain

ドキュメントの配列

任意

インデックスごとのパーティションの詳細が含まれています。これは2つ以上のインデックス パーティションを設定した場合にのみ返されます。

metadata

ドキュメント

任意

有用なメタデータを含んでいます。

query

ドキュメント

任意

クエリの実行統計を記述します。これは返されません。 indexPartitionExplain が存在する場合、これは最上位ではなく各 indexPartitionExplain 内にネストされます。

resultMaterialization

ドキュメント

任意

クエリ実行後に Lucene からドキュメントごとのデータを取得するための詳細。queryPlanner の冗長モードでは返されません。

resourceUsage

ドキュメント

任意

クエリが実行されたときのリソース使用状況を詳述します。queryPlannerの冗長モードでは返されません。

collectors BSON ドキュメントには、次のフィールドが含まれています。

フィールド
タイプ
必要性
目的

allCollectorStats

ドキュメント

必須

クエリのすべてのコレクターの統計情報。報告される統計は、クエリで使用されるすべてのコレクターにわたる最大値または、すべてのサブコレクションにわたる統計の合計を表します。タイミング統計は、クエリ全体のすべてのコレクターで費やされた合計時間を反映するように合計されます。詳しくは allCollectorStats を参照してください。

facet

ドキュメント

任意

ファセットを指定するクエリの内訳。詳細については、facet をご覧ください。

sort

ドキュメント

任意

ソートを指定するクエリの内訳です。詳細については、sort をご覧ください。

allCollectorStats BSON ドキュメントには、クエリで指定されたすべてのコレクターの統計が記述されており、facetsort が含まれます。これには、次のキーが含まれています。

フィールド
説明

collect

コレクターが収集した期間と結果の数を追跡します。

competitiveIterator

コレクターから competitiveIterator が要求された合計時間と回数を追跡する統計。

setScorer

スコアラーがコレクターに設定された合計時間と回数を追跡する統計。

facet は、BSON ドキュメントであり、クエリにファセットを指定した場合のクエリおよび実行統計を詳細に示します。次のフィールドが含まれています。

オプション
タイプ
必要性
目的

collectorStats

ドキュメント

任意

facet コレクターの統計のみを表示します。ここにあるキーは allCollectorStats と同一です。クエリで sort を使用した場合は、これと allCollectorStats との差を評価して、sort コレクターの実行統計を判定できます。

createCountsStats

ドキュメント

任意

すべてのファセット グループを保持する内部の Lucene オブジェクトの作成に関連する統計を表示します。generateFacetCounts フィールドが含まれており、mongot がすべてのファセットとそのカウントを保持する Lucene オブジェクトを生成する合計期間と回数を追跡する統計を返します。

stringFacetFieldCardinalities

ドキュメント

必須

クエリに一致したドキュメントと Lucene インデックス全体の両方に対して、ファセット対象のフィールドをその濃度にマッピングします。これにより、各フィールドについて次の濃度情報が提供されます。

  • queried - クエリされたすべてのドキュメントにわたるフィールドのファセット濃度を表します。

  • total - インデックス内のすべてのドキュメントにわたるフィールドのファセット濃度を表します。

sort は、クエリでソートを指定したときに、クエリと実行統計を詳細に示す BSON ドキュメントです。次のフィールドが含まれています。

オプション
タイプ
必要性
目的

stats

ドキュメント

任意

すべてのソート フィールドにわたる sort の実行に関連する統計を追跡します。次のフィールドが含まれています。

  • comparator - Lucene が結果をソートする方法に関する統計およびメタデータを表示します。

    • setBottom - 現在競合が最も少ないソート値が、新しい競合値でアップデートされる頻度を返します。ソート時に、 MongoDB Search は下限値を追跡します。新しい値が関連性または競合性において現在の下限値を超えると、このメトリクスは増加します。

    • compareBottom - 現在の bottom 値と候補の bottom 値を比較する際のタイミングおよび呼び出しに関する統計を返します。

    • compareTop - 現在の top 値と候補の top 値を比較する際のタイミングおよび呼び出しに関する統計を返します。

    • setHitsThresholdReached - 最大結果数(limit)に達した際のタイミングと呼び出しに関する統計を返します。

    • competitiveIterator - ソートされた結果で上位をめぐって競合する可能性のあるドキュメントの反復処理に関連するタイミングと呼び出しの統計情報のみを返します。

    • setScorer - ドキュメントのスコアと関連性の計算に関連するタイミングと呼び出しの統計を返します。

  • prunedResultIterator - Lucene のcompetitiveIteratorにおけるnextDocおよびadvanceメソッド呼び出しの回数とタイミングの統計を表示します。

    混合データ型のソートを実行する場合、これは出力に表示されません。

    nextDocフィールドのみが含まれています。

fieldInfos

ドキュメント

必須

ソート対象のフィールドを、そのフィールドのインデックスに存在するデータ型のリストにマッピングします。

highlight は、クエリでハイライトを指定した場合に、クエリと実行の統計を詳細に示す BSON ドキュメントです。次のフィールドが含まれています。

オプション
タイプ
必要性
目的

resolvedHighlightPaths

List<String>

必須

ハイライトされたすべてのフィールドの一覧。クエリの highlight セクションでワイルドカード パスを指定した場合、完全に解決されたドキュメント パスのリストが含まれています。

stats

QueryExecutionArea

任意

ハイライトの設定および実行に関連する呼び出しとタイミングの統計。次のフィールドが含まれています。

  • setupHighlight - executeHighlight フェーズ中に使用される内部 Lucene オブジェクトのセットアップに要した時間。

  • executeHighlight - 一致するドキュメントに対してハイライトを実行するのに要した時間。

indexPartitionExplain には、各インデックス パーティションの結果説明が含まれています。最上位の collectorsquery は各インデックス パーティションの explain 情報内にあり、最上位レベルには存在しません。

metadata には、次のような有用なメタデータが含まれています。

フィールド
タイプ
必要性
目的

mongotVersion

文字列

任意

mongotの現在のバージョンです。

mongotHostName

文字列

任意

mongot ホストを識別する、人間が判読できるラベル。

indexName

文字列

任意

クエリで使用されるMongoDB Searchインデックス。

cursorOptions

ドキュメント

任意

mongot に指定されたカーソル オプション。

totalLuceneDocs

整数

任意

削除されたドキュメントを含むインデックス内のインデックス オブジェクトの総数。

query BSON ドキュメントには、クエリの実行統計が記述されています。次のフィールドが含まれています。

フィールド
タイプ
必要性
目的

path

string

任意

演算子へのパス(ルートでない場合のみ)。

type

string

必須

MongoDB Search 演算子が作成した Lucene クエリの名前。詳しくは、 query を参照してください。

analyzer

string

任意

クエリで使用されるMongoDB Searchアナライザ。

args

ドキュメント

必須

Lucene クエリ情報。詳細については、queryをご覧ください。

stats

ドキュメント

任意

explainexecutionStats または allPlansExecution の冗長度で実行された場合、クエリの stats

検索コマンドの explain 応答 には、そのコマンドで実行されたクエリに関する情報が含まれます。argsフィールドの応答には、 MongoDB Search が $search クエリを満たすために実行した Lucene クエリの構造化された詳細が含まれます。

このセクションには、次の内容が含まれています。

  • MongoDB Search 演算子が作成する Lucene クエリの一部

  • 構造化サマリーに含まれる Lucene クエリ オプション

  • 各 Lucene クエリ タイプの Lucene クエリ構造の概要の例

注意

例について

このセクションの例は、サンプル データセットに対して queryPlanner 冗長モードで実行されたクエリに基づいています。この例の応答は、次のようになります。

  • mongotQuery フィールドには、 MongoDB Search 演算子と実行されたクエリが表示されます。

  • explain.type フィールドには、演算子が作成した Lucene クエリが表示されます。

完全な例については、「」を参照してください。

BooleanQuery

Lucene BooleanQueryの場合、構造化されたサマリーには次のオプションに関する詳細が含まれます。

フィールド
タイプ
必要性
説明

must

任意

一致する必要がある句。

mustNot

任意

一致してはならない句。

should

任意

一致する必要がある句。

filter

任意

すべて一致する必要がある句。

minimumShouldMatch

整数

任意

一致する必要があるshould句の最小数。

ConstantScoreQuery

定数スコアクエリの場合、構造化されたサマリーには次のオプションの詳細が含まれます。

フィールド
タイプ
必要性
説明

query

必須

ConstantScoreQueryの子。

次の例では、 sample_airbnb.listingsAndReviewsコレクションに対してクエリを実行した場合のexplain応答を示しています。

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

Lucene FunctionScoreQueryクエリの場合、構造化されたサマリーには次のオプションに関する詳細が含まれます。

フィールド
タイプ
必要性
説明

scoreFunction

string

必須

クエリで使用される スコア式 。

query

必須

クエリ。

次の例では、 sample_airbnb.listingsAndReviewsコレクションに対してクエリを実行した場合のexplain応答を示しています。

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

Lucene LatLonPointDistanceQuery クエリの場合、応答には stats のみが含まれます。

次の例では、 sample_airbnb.listingsAndReviewsコレクションに対してクエリを実行した場合のexplain応答を示しています。

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

Lucene LatLonShapeQuery クエリの場合、応答には stats のみが含まれます。

次の例では、 sample_airbnb.listingsAndReviewsコレクションに対してクエリを実行した場合のexplain応答を示しています。

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

Lucene LongDistanceFeatureQuery の場合、応答には stats のみが含まれます。

次の例では、 sample_mflix.moviesコレクションに対してクエリを実行した場合のexplain応答を示しています。

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

Lucene MultiTermQueryConstantScoreWrapperクエリの場合、構造化されたサマリーには次の引数に関する詳細が含まれます。

フィールド
タイプ
必要性
説明

queries

必須

クエリのリスト。

次の例では、 sample_airbnb.listingsAndReviewsコレクションに対してクエリを実行した場合のexplain応答を示しています。

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

Lucene PhraseQueryクエリの場合、構造化されたサマリーには次の引数に関する詳細が含まれます。

フィールド
タイプ
必要性
説明

path

文字列

必須

検索するインデックス付きフィールド。

query

文字列

必須

検索する文字列または複数の文字列。

slop

番号

必須

queryフレーズ内の単語間の許容距離。

次の例では、 sample_airbnb.listingsAndReviewsコレクションに対してクエリを実行した場合のexplain応答を示しています。

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

Lucene PointRangeQueryクエリの場合、構造化されたサマリーには次の引数に関する詳細が含まれます。

フィールド
タイプ
必要性
説明

path

文字列

必須

検索するインデックス付きフィールド。

representation

文字列

任意

数値表現。 日付型データに対するクエリには表現は含まれません。

gte

番号

任意

クエリの下限。

lte

番号

任意

クエリの上限。

次の例では、 sample_airbnb.listingsAndReviewsコレクションに対してクエリを実行した場合のexplain応答を示しています。

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

ターム クエリの場合、構造化されたサマリーには次の引数に関する詳細が含まれます。

フィールド
タイプ
必要性
説明

path

文字列

必須

検索するインデックス付きフィールド。

value

文字列

必須

検索する string。

次の例では、 sample_airbnb.listingsAndReviewsコレクションに対してクエリを実行した場合のexplain応答を示しています。

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 クエリによって明示的に定義されていない Lucene クエリは、デフォルトのクエリを使用して直列化されます。 構造化されたサマリーには、次のオプションの詳細が含まれます。

フィールド
タイプ
必要性
説明

queryType

文字列

必須。

Lucene クエリのタイプ。

次の例では、 sample_airbnb.listingsAndReviewsコレクションに対してクエリを実行した場合のexplain応答を示しています。

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}

executionStatsallPlansExecution の冗長モードのexplain レスポンスにはstats 、クエリ実行のさまざまな段階でクエリ に費やされた 時間 に関する情報を含む フィールドが含まれています。

タイミングの内訳は、クエリ実行の領域に関連する実行統計を示します。次のフィールドは、タイミングの内訳を示しています。

フィールド
タイプ
説明

millisElapsed

Long

この領域でクエリの子がこの領域 で費やした時間数を含む、この領域でタスクの実行に経過したおおよそのウォールクロック時間。値は、この領域でタスクを実行中に経過したおおよそのミリ秒数です。

invocationCounts

ドキュメント

この領域 に含まれるタスクの呼び出しの数。この値は、タスク名とその呼び出し回数のマッピングです。

統計は、クエリの次の領域で利用できます。

オプション
説明

context

Lucene クエリの実行に関連する統計。 この領域には、呼び出し回数が列挙されるタスクが 2 つあります。

createScorer

スコアリングはドキュメントを反復処理し、各ドキュメントに対してスコアを生成します。 createScorerを呼び出すと、スコアリングを担当するオブジェクトが作成されます。 このタスクに関連付けられている時間は、実際にドキュメントのスコアリングに費やされた時間ではないことに注意してください。 カウントにはscorerSupplier呼び出しの数が含まれます。

createWeight

重みはクエリとIndexSearcherに関連付けられた状態を保存します。 カウントにはcreateWeight呼び出しの数が含まれます。

この領域で費やされる時間はクエリの構造に関連しており、反復処理されスコア付けされる結果の数には基づいていません。

以下に例を挙げます。

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

match

結果ドキュメントの反復処理と一致に関連する統計。 この統計は、どのドキュメントが次の一致であるかを決定するのにかかる時間を示しています。 結果のマッチングに費やされる時間は、クエリの性質によって大きく異なる場合があります。 この領域には、呼び出し回数が列挙されるタスクが 2 つあります。

nextDoc

結果セットの次のドキュメントに進むことを要求します。 これには、スキップを識別して過去のスキップに移動するか、次の一致を見つけるために必要なその他のタスクが含まれます。 カウントには、 nextDocadvanceの呼び出しの数が含まれます。

refineRoughMatch

より完全な一致を実行します。 一部のクエリは 2 段階のプロセスで実行されます。このプロセスではドキュメントは最初に「ほぼ」一致し、最初のおおよその一致を満たした後にのみ、2 番目のより詳細なフェーズでチェックされます。 refineRoughMatchタスクは、2 フェーズ プロセスの 2 番目のフェーズです。 カウントにはrefineRoughMatch呼び出しの数が含まれます。

以下に例を挙げます。

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

score

結果セット内のドキュメントのスコアリングに関連する統計。 この領域には、呼び出し回数が列挙されるタスクが 2 つあります。

score

結果セット内の各ドキュメントにスコアを付けます。 カウントにはscore呼び出しの数が含まれます。

setMinCompetitiveScore

指定された値よりスコアが小さいドキュメントを無視します。 スコアが一定の非競合しきい値を下回るドキュメントを無視することで、クエリが実行されるスコアリング操作の数を減らすことができた可能性があることを示します。 カウントにはsetMinCompetitiveScore呼び出しの数が含まれます。

以下に例を挙げます。

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

resultMaterialization ドキュメントは、mongot が次の操作を実行するのにかかる時間を示しています。

  1. Lucene に保存されている結果データを _id または storedSource の形式で検索します。

  2. mongod に送信する前に、データを BSON 形式にシリアル化してください。

詳細については、stats をご覧ください。

resourceUsage ドキュメントには、クエリの実行に使用されるリソースが表示されます。次のフィールドが含まれています。

フィールド
タイプ
必要性
目的

majorFaults

Long

必須

クエリ実行中にシステムがメモリ内で必要なデータを見つけられず、ディスクなどのバッキング ストアから読み込む場合に発生するメジャーなページ フォールトの数。

minorFaults

Long

必須

データがページキャッシュにあるが、まだプロセスのページテーブルにマップされていない場合に発生するマイナーページフォールトの数。

userTimeMs

Long

必須

ユーザー空間で費やされた CPU 時間(ミリ秒単位)。

systemTimeMs

Long

必須

システム空間で費やされた CPU 時間(ミリ秒単位)。

maxReportingThreads

整数

必須

すべてのバッチでのクエリ実行中にmongotが使用したスレッドの最大数。非並行のExplainクエリの場合、値は1です。

numBatches

整数

必須

クエリのプロセシング中に mongot が要求されたバッチの総数。

次の例えでは、sample_mflix データベースの movies コレクションを使用します。

次の例では、さまざまな演算子を使用して、title フィールドを allPlansExecution 冗長モードでクエリします。

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: 'mark' },
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.209279,
37 invocationCounts: {
38 createWeight: Long('2'),
39 createScorer: Long('18')
40 }
41 },
42 match: {
43 millisElapsed: 0.028079,
44 invocationCounts: { nextDoc: Long('22') }
45 },
46 score: {
47 millisElapsed: 0.01706,
48 invocationCounts: { score: Long('16') }
49 }
50 }
51 },
52 {
53 type: 'BoostQuery',
54 args: {
55 query: {
56 type: 'TermQuery',
57 args: { path: 'title', value: 'yard' },
58 stats: {
59 context: { millisElapsed: 0 },
60 match: { millisElapsed: 0 },
61 score: { millisElapsed: 0 }
62 }
63 },
64 boost: 0.75
65 },
66 stats: {
67 context: {
68 millisElapsed: 0.136254,
69 invocationCounts: {
70 createWeight: Long('2'),
71 createScorer: Long('14')
72 }
73 },
74 match: {
75 millisElapsed: 0.008556,
76 invocationCounts: { nextDoc: Long('10') }
77 },
78 score: {
79 millisElapsed: 0.006096,
80 invocationCounts: { score: Long('6') }
81 }
82 }
83 },
84 {
85 type: 'BoostQuery',
86 args: {
87 query: {
88 type: 'TermQuery',
89 args: { path: 'title', value: 'york' },
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.303568,
101 invocationCounts: {
102 createWeight: Long('2'),
103 createScorer: Long('18')
104 }
105 },
106 match: {
107 millisElapsed: 0.374856,
108 invocationCounts: { nextDoc: Long('62') }
109 },
110 score: {
111 millisElapsed: 0.892383,
112 invocationCounts: { score: Long('56') }
113 }
114 }
115 },
116 {
117 type: 'BoostQuery',
118 args: {
119 query: {
120 type: 'TermQuery',
121 args: { path: 'title', value: 'ark' },
122 stats: {
123 context: { millisElapsed: 0 },
124 match: { millisElapsed: 0 },
125 score: { millisElapsed: 0 }
126 }
127 },
128 boost: 0.6666666269302368
129 },
130 stats: {
131 context: {
132 millisElapsed: 8.379562,
133 invocationCounts: {
134 createWeight: Long('2'),
135 createScorer: Long('10')
136 }
137 },
138 match: {
139 millisElapsed: 2.073272,
140 invocationCounts: { nextDoc: Long('6') }
141 },
142 score: {
143 millisElapsed: 0.004063,
144 invocationCounts: { score: Long('4') }
145 }
146 }
147 },
148 {
149 type: 'BoostQuery',
150 args: {
151 query: {
152 type: 'TermQuery',
153 args: { path: 'title', value: 'dark' },
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.679029,
165 invocationCounts: {
166 createWeight: Long('2'),
167 createScorer: Long('18')
168 }
169 },
170 match: {
171 millisElapsed: 5.500198,
172 invocationCounts: { nextDoc: Long('172') }
173 },
174 score: {
175 millisElapsed: 2.465502,
176 invocationCounts: { score: Long('166') }
177 }
178 }
179 },
180 {
181 type: 'BoostQuery',
182 args: {
183 query: {
184 type: 'TermQuery',
185 args: { path: 'title', value: 'park' },
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.221919,
197 invocationCounts: {
198 createWeight: Long('2'),
199 createScorer: Long('18')
200 }
201 },
202 match: {
203 millisElapsed: 0.116139,
204 invocationCounts: { nextDoc: Long('60') }
205 },
206 score: {
207 millisElapsed: 0.056817,
208 invocationCounts: { score: Long('54') }
209 }
210 }
211 }
212 ],
213 filter: [],
214 minimumShouldMatch: 0
215 },
216 stats: {
217 context: {
218 millisElapsed: 25.303419,
219 invocationCounts: { createWeight: Long('2'), createScorer: Long('12') }
220 },
221 match: {
222 millisElapsed: 10.533183,
223 invocationCounts: { nextDoc: Long('308') }
224 },
225 score: {
226 millisElapsed: 5.501189,
227 invocationCounts: { score: Long('302') }
228 }
229 }
230 },
231 collectStats: {
232 allCollectorStats: {
233 millisElapsed: 6.735626,
234 invocationCounts: {
235 collect: Long('302'),
236 competitiveIterator: Long('6'),
237 setScorer: Long('6')
238 }
239 },
240 facet: { collectorStats: { millisElapsed: 0 } }
241 },
242 resultMaterialization: {
243 stats: {
244 millisElapsed: 176.613905,
245 invocationCounts: { retrieveAndSerialize: Long('2') }
246 }
247 },
248 metadata: {
249 <hostname>.mongodb.netmongotVersion: '1.42.0',
250 mongotHostName: '<hostname>.mongodb.net',
251 indexName: 'default',
252 cursorOptions: { batchSize: 108, requiresSearchSequenceToken: false },
253 totalLuceneDocs: 21349
254 },
255 resourceUsage: {
256 majorFaults: Long('99'),
257 minorFaults: Long('192'),
258 userTimeMs: Long('80'),
259 systemTimeMs: Long('10'),
260 maxReportingThreads: 1,
261 numBatches: 2
262 }
263 },
264 requiresSearchMetaCursor: false,
265 internalMongotBatchSizeHistory: [ Long('108'), Long('162') ]
266 },
267 nReturned: Long('151'),
268 executionTimeMillisEstimate: Long('83')
269 },
270 {
271 '$_internalSearchIdLookup': {
272 subPipeline: [
273 { '$match': { _id: { '$eq': '_id placeholder' } } }
274 ],
275 totalDocsExamined: Long('151'),
276 totalKeysExamined: Long('151'),
277 numDocsFilteredByIdLookup: Long('0')
278 },
279 nReturned: Long('151'),
280 executionTimeMillisEstimate: Long('88')
281 }
282 ],
283 queryShapeHash: '6FD3791F785FA329D4ECD1171E0E5AF6772C18F5F0A7A50FC416D080A93C8CB7',
284 serverInfo: {
285 host: '<hostname>.mongodb.net',
286 port: 27017,
287 version: '8.2.0',
288 gitVersion: '13e629eeccd63f00d17568fc4c12b7530fa34b54'
289 },
290 serverParameters: {
291 ...
292 },
293 command: {
294 aggregate: 'movies',
295 pipeline: [
296 {
297 '$search': {
298 text: {
299 path: 'title',
300 query: 'yark',
301 fuzzy: { maxEdits: 1, maxExpansions: 100 }
302 }
303 }
304 }
305 ],
306 cursor: {},
307 '$db': 'sample_mflix'
308 },
309 ok: 1,
310 '$clusterTime': {
311 clusterTime: Timestamp({ t: 1758295936, i: 19 }),
312 signature: {
313 hash: Binary.createFromBase64('+CanjrL9jdXPTLa2sUaNPtImkBc=', 0),
314 keyId: Long('7551379485140975621')
315 }
316 },
317 operationTime: Timestamp({ t: 1758295936, i: 19 })
318}
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: 9.880819,
17 invocationCounts: { createWeight: Long('1'), createScorer: Long('6') }
18 },
19 match: {
20 millisElapsed: 3.566358,
21 invocationCounts: { nextDoc: Long('28') }
22 },
23 score: {
24 millisElapsed: 2.762687,
25 invocationCounts: { score: Long('25') }
26 }
27 }
28 },
29 collectStats: {
30 allCollectorStats: {
31 millisElapsed: 3.238152,
32 invocationCounts: {
33 collect: Long('25'),
34 competitiveIterator: Long('3'),
35 setScorer: Long('3')
36 }
37 },
38 facet: { collectorStats: { millisElapsed: 0 } }
39 },
40 highlight: {
41 resolvedHighlightPaths: [ '$type:string/title' ],
42 stats: {
43 millisElapsed: 157.543967,
44 invocationCounts: {
45 executeHighlight: Long('1'),
46 setupHighlight: Long('1')
47 }
48 }
49 },
50 resultMaterialization: {
51 stats: {
52 millisElapsed: 3.781115,
53 invocationCounts: { retrieveAndSerialize: Long('1') }
54 }
55 },
56 metadata: {
57 <hostname>.mongodb.netmongotVersion: '1.42.0',
58 mongotHostName: '<hostname>.mongodb.net',
59 indexName: 'default',
60 cursorOptions: { batchSize: 108, requiresSearchSequenceToken: false },
61 totalLuceneDocs: 21349
62 },
63 resourceUsage: {
64 majorFaults: Long('42'),
65 minorFaults: Long('167'),
66 userTimeMs: Long('50'),
67 systemTimeMs: Long('0'),
68 maxReportingThreads: 1,
69 numBatches: 1
70 }
71 },
72 requiresSearchMetaCursor: false,
73 internalMongotBatchSizeHistory: [ Long('108') ]
74 },
75 nReturned: Long('25'),
76 executionTimeMillisEstimate: Long('0')
77 },
78 {
79 '$_internalSearchIdLookup': {
80 subPipeline: [
81 { '$match': { _id: { '$eq': '_id placeholder' } } }
82 ],
83 totalDocsExamined: Long('25'),
84 totalKeysExamined: Long('25'),
85 numDocsFilteredByIdLookup: Long('0')
86 },
87 nReturned: Long('25'),
88 executionTimeMillisEstimate: Long('1')
89 },
90 {
91 '$project': {
92 description: true,
93 highlights: { '$meta': 'searchHighlights' },
94 _id: false
95 },
96 nReturned: Long('25'),
97 executionTimeMillisEstimate: Long('1')
98 }
99 ],
100 queryShapeHash: 'D08444272924C1E04A6E99D0CD4BF82FD929893862B3356F79EC18BBD1F0EF0C',
101 serverInfo: {
102 host: '<hostname>.mongodb.net',
103 port: 27017,
104 version: '8.2.0',
105 gitVersion: '13e629eeccd63f00d17568fc4c12b7530fa34b54'
106 },
107 serverParameters: {
108 internalQueryFacetBufferSizeBytes: 104857600,
109 internalQueryFacetMaxOutputDocSizeBytes: 104857600,
110 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
111 internalDocumentSourceGroupMaxMemoryBytes: 104857600,
112 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
113 internalQueryProhibitBlockingMergeOnMongoS: 0,
114 internalQueryMaxAddToSetBytes: 104857600,
115 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
116 internalQueryFrameworkControl: 'trySbeRestricted',
117 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
118 },
119 command: {
120 aggregate: 'movies',
121 pipeline: [
122 {
123 '$search': {
124 text: { path: 'title', query: 'prince' },
125 highlight: { path: 'title', maxNumPassages: 1, maxCharsToExamine: 40 }
126 }
127 },
128 {
129 '$project': {
130 description: 1,
131 _id: 0,
132 highlights: { '$meta': 'searchHighlights' }
133 }
134 }
135 ],
136 cursor: {},
137 '$db': 'sample_mflix'
138 },
139 ok: 1,
140 '$clusterTime': {
141 clusterTime: Timestamp({ t: 1758302099, i: 1 }),
142 signature: {
143 hash: Binary.createFromBase64('pUGxwCVnDOBIObmhURJQ1a1UwC8=', 0),
144 keyId: Long('7551379485140975621')
145 }
146 },
147 operationTime: Timestamp({ t: 1758302099, i: 1 })
148}
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: 4.141763,
32 invocationCounts: { createWeight: Long('1'), createScorer: Long('6') }
33 },
34 match: {
35 millisElapsed: 24.986327,
36 invocationCounts: { nextDoc: Long('20881') }
37 },
38 score: {
39 millisElapsed: 33.324657,
40 invocationCounts: { score: Long('20878') }
41 }
42 }
43 },
44 collectStats: {
45 allCollectorStats: {
46 millisElapsed: 72.243101,
47 invocationCounts: {
48 collect: Long('20878'),
49 competitiveIterator: Long('3'),
50 setScorer: Long('3')
51 }
52 },
53 facet: {
54 collectorStats: {
55 millisElapsed: 10.424621,
56 invocationCounts: { collect: Long('20878'), setScorer: Long('3') }
57 },
58 createCountsStats: {
59 millisElapsed: 60.095261,
60 invocationCounts: { generateFacetCounts: Long('2') }
61 },
62 stringFacetCardinalities: { genresFacet: { queried: 10, total: 25 } }
63 }
64 },
65 resultMaterialization: {
66 stats: {
67 millisElapsed: 13.764287,
68 invocationCounts: { retrieveAndSerialize: Long('1') }
69 }
70 },
71 metadata: {
72 <hostname>.mongodb.netmongotVersion: '1.42.0',
73 mongotHostName: '<hostname>.mongodb.net',
74 indexName: 'default',
75 totalLuceneDocs: 21349
76 },
77 resourceUsage: {
78 majorFaults: Long('10'),
79 minorFaults: Long('13'),
80 userTimeMs: Long('20'),
81 systemTimeMs: Long('0'),
82 maxReportingThreads: 1,
83 numBatches: 1
84 }
85 },
86 requiresSearchMetaCursor: true
87 },
88 nReturned: Long('1'),
89 executionTimeMillisEstimate: Long('336')
90 }
91 ],
92 queryShapeHash: '582DB864C9BCFB96896CF1A3079CF70FAC10A9A1E19E8D66DF20A2BB40424FB5',
93 serverInfo: {
94 host: '<hostname>.mongodb.net',
95 port: 27017,
96 version: '8.2.0',
97 gitVersion: '13e629eeccd63f00d17568fc4c12b7530fa34b54'
98 },
99 serverParameters: {
100 ...
101 },
102 command: {
103 aggregate: 'movies',
104 pipeline: [
105 {
106 '$searchMeta': {
107 facet: {
108 operator: {
109 near: {
110 path: 'released',
111 origin: ISODate('1921-11-01T00:00:00.000Z'),
112 pivot: 7776000000
113 }
114 },
115 facets: {
116 genresFacet: { type: 'string', path: 'genres' },
117 yearFacet: {
118 type: 'number',
119 path: 'year',
120 boundaries: [ 1910, 1920, 1930, 1940 ]
121 }
122 }
123 }
124 }
125 }
126 ],
127 cursor: {},
128 '$db': 'sample_mflix'
129 },
130 ok: 1,
131 '$clusterTime': {
132 clusterTime: Timestamp({ t: 1758304279, i: 1 }),
133 signature: {
134 hash: Binary.createFromBase64('DI9+ZTogU1QxHCWId6QLcA4R4tQ=', 0),
135 keyId: Long('7551379485140975621')
136 }
137 },
138 operationTime: Timestamp({ t: 1758304279, i: 1 })
139}
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: 'mark' },
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.164466,
37 invocationCounts: {
38 createWeight: Long('2'),
39 createScorer: Long('18')
40 }
41 },
42 match: {
43 millisElapsed: 0.055889,
44 invocationCounts: { nextDoc: Long('22') }
45 },
46 score: {
47 millisElapsed: 0.01638,
48 invocationCounts: { score: Long('16') }
49 }
50 }
51 },
52 {
53 type: 'BoostQuery',
54 args: {
55 query: {
56 type: 'TermQuery',
57 args: { path: 'title', value: 'yard' },
58 stats: {
59 context: { millisElapsed: 0 },
60 match: { millisElapsed: 0 },
61 score: { millisElapsed: 0 }
62 }
63 },
64 boost: 0.75
65 },
66 stats: {
67 context: {
68 millisElapsed: 0.109841,
69 invocationCounts: {
70 createWeight: Long('2'),
71 createScorer: Long('14')
72 }
73 },
74 match: {
75 millisElapsed: 0.009747,
76 invocationCounts: { nextDoc: Long('10') }
77 },
78 score: {
79 millisElapsed: 0.005449,
80 invocationCounts: { score: Long('6') }
81 }
82 }
83 },
84 {
85 type: 'BoostQuery',
86 args: {
87 query: {
88 type: 'TermQuery',
89 args: { path: 'title', value: 'york' },
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.140144,
101 invocationCounts: {
102 createWeight: Long('2'),
103 createScorer: Long('18')
104 }
105 },
106 match: {
107 millisElapsed: 0.058885,
108 invocationCounts: { nextDoc: Long('62') }
109 },
110 score: {
111 millisElapsed: 0.877508,
112 invocationCounts: { score: Long('56') }
113 }
114 }
115 },
116 {
117 type: 'BoostQuery',
118 args: {
119 query: {
120 type: 'TermQuery',
121 args: { path: 'title', value: 'ark' },
122 stats: {
123 context: { millisElapsed: 0 },
124 match: { millisElapsed: 0 },
125 score: { millisElapsed: 0 }
126 }
127 },
128 boost: 0.6666666269302368
129 },
130 stats: {
131 context: {
132 millisElapsed: 0.26056,
133 invocationCounts: {
134 createWeight: Long('2'),
135 createScorer: Long('10')
136 }
137 },
138 match: {
139 millisElapsed: 1.028141,
140 invocationCounts: { nextDoc: Long('6') }
141 },
142 score: {
143 millisElapsed: 0.004226,
144 invocationCounts: { score: Long('4') }
145 }
146 }
147 },
148 {
149 type: 'BoostQuery',
150 args: {
151 query: {
152 type: 'TermQuery',
153 args: { path: 'title', value: 'dark' },
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.3029,
165 invocationCounts: {
166 createWeight: Long('2'),
167 createScorer: Long('18')
168 }
169 },
170 match: {
171 millisElapsed: 2.294511,
172 invocationCounts: { nextDoc: Long('172') }
173 },
174 score: {
175 millisElapsed: 1.806661,
176 invocationCounts: { score: Long('166') }
177 }
178 }
179 },
180 {
181 type: 'BoostQuery',
182 args: {
183 query: {
184 type: 'TermQuery',
185 args: { path: 'title', value: 'park' },
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.154143,
197 invocationCounts: {
198 createWeight: Long('2'),
199 createScorer: Long('18')
200 }
201 },
202 match: {
203 millisElapsed: 0.052283,
204 invocationCounts: { nextDoc: Long('60') }
205 },
206 score: {
207 millisElapsed: 0.050278,
208 invocationCounts: { score: Long('54') }
209 }
210 }
211 }
212 ],
213 filter: [],
214 minimumShouldMatch: 0
215 },
216 stats: {
217 context: {
218 millisElapsed: 2.024454,
219 invocationCounts: { createWeight: Long('2'), createScorer: Long('12') }
220 },
221 match: {
222 millisElapsed: 4.020593,
223 invocationCounts: { nextDoc: Long('308') }
224 },
225 score: {
226 millisElapsed: 3.181962,
227 invocationCounts: { score: Long('302') }
228 }
229 }
230 },
231 collectStats: {
232 allCollectorStats: {
233 millisElapsed: 4.062801,
234 invocationCounts: {
235 collect: Long('302'),
236 competitiveIterator: Long('6'),
237 setScorer: Long('6')
238 }
239 },
240 facet: { collectorStats: { millisElapsed: 0 } }
241 },
242 resultMaterialization: {
243 stats: {
244 millisElapsed: 127.205476,
245 invocationCounts: { retrieveAndSerialize: Long('2') }
246 }
247 },
248 metadata: {
249 <hostname>.mongodb.netmongotVersion: '1.42.0',
250 mongotHostName: '<hostname>.mongodb.net',
251 indexName: 'default',
252 cursorOptions: { batchSize: 108, requiresSearchSequenceToken: false },
253 totalLuceneDocs: 21349
254 },
255 resourceUsage: {
256 majorFaults: Long('100'),
257 minorFaults: Long('31'),
258 userTimeMs: Long('20'),
259 systemTimeMs: Long('10'),
260 maxReportingThreads: 1,
261 numBatches: 2
262 }
263 },
264 requiresSearchMetaCursor: false,
265 internalMongotBatchSizeHistory: [ Long('108'), Long('162') ]
266 },
267 nReturned: Long('151'),
268 executionTimeMillisEstimate: Long('57')
269 },
270 {
271 '$_internalSearchIdLookup': {
272 subPipeline: [
273 { '$match': { _id: { '$eq': '_id placeholder' } } }
274 ],
275 totalDocsExamined: Long('151'),
276 totalKeysExamined: Long('151'),
277 numDocsFilteredByIdLookup: Long('0')
278 },
279 nReturned: Long('151'),
280 executionTimeMillisEstimate: Long('64')
281 }
282 ],
283 queryShapeHash: '6FD3791F785FA329D4ECD1171E0E5AF6772C18F5F0A7A50FC416D080A93C8CB7',
284 serverInfo: {
285 host: '<hostname>.mongodb.net',
286 port: 27017,
287 version: '8.2.0',
288 gitVersion: '13e629eeccd63f00d17568fc4c12b7530fa34b54'
289 },
290 serverParameters: {
291 ...
292 },
293 command: {
294 aggregate: 'movies',
295 pipeline: [
296 {
297 '$search': {
298 text: {
299 path: 'title',
300 query: 'yark',
301 fuzzy: { maxEdits: 1, maxExpansions: 100 }
302 }
303 }
304 }
305 ],
306 cursor: {},
307 '$db': 'sample_mflix'
308 },
309 ok: 1,
310 '$clusterTime': {
311 clusterTime: Timestamp({ t: 1758302299, i: 1 }),
312 signature: {
313 hash: Binary.createFromBase64('pCKOPlBY/K4IObOkqDlOSnbRqw0=', 0),
314 keyId: Long('7551379485140975621')
315 }
316 },
317 operationTime: Timestamp({ t: 1758302299, i: 1 })
318}

次の例では、さまざまな演算子を使用して、title フィールドを queryPlanner 冗長モードでクエリします。

db.movies.explain("queryPlanner").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: 'park' }
26 },
27 boost: 0.75
28 }
29 },
30 {
31 type: 'BoostQuery',
32 args: {
33 query: {
34 type: 'TermQuery',
35 args: { path: 'title', value: 'york' }
36 },
37 boost: 0.75
38 }
39 },
40 {
41 type: 'BoostQuery',
42 args: {
43 query: {
44 type: 'TermQuery',
45 args: { path: 'title', value: 'dark' }
46 },
47 boost: 0.75
48 }
49 },
50 {
51 type: 'BoostQuery',
52 args: {
53 query: {
54 type: 'TermQuery',
55 args: { path: 'title', value: 'mark' }
56 },
57 boost: 0.75
58 }
59 },
60 {
61 type: 'BoostQuery',
62 args: {
63 query: {
64 type: 'TermQuery',
65 args: { path: 'title', value: 'yard' }
66 },
67 boost: 0.75
68 }
69 },
70 {
71 type: 'BoostQuery',
72 args: {
73 query: {
74 type: 'TermQuery',
75 args: { path: 'title', value: 'ark' }
76 },
77 boost: 0.6666666269302368
78 }
79 }
80 ],
81 filter: [],
82 minimumShouldMatch: 0
83 }
84 },
85 metadata: {
86 <hostname>.mongodb.netmongotVersion: '1.42.0',
87 mongotHostName: '<hostname>.mongodb.net',
88 indexName: 'default',
89 totalLuceneDocs: 21349
90 }
91 },
92 requiresSearchMetaCursor: false
93 }
94 },
95 {
96 '$_internalSearchIdLookup': {
97 subPipeline: [
98 { '$match': { _id: { '$eq': '_id placeholder' } } }
99 ]
100 }
101 }
102 ],
103 queryShapeHash: '6FD3791F785FA329D4ECD1171E0E5AF6772C18F5F0A7A50FC416D080A93C8CB7',
104 serverInfo: {
105 host: '<hostname>.mongodb.net',
106 port: 27017,
107 version: '8.2.0',
108 gitVersion: '13e629eeccd63f00d17568fc4c12b7530fa34b54'
109 },
110 serverParameters: {
111 ...
112 },
113 command: {
114 aggregate: 'movies',
115 pipeline: [
116 {
117 '$search': {
118 text: {
119 path: 'title',
120 query: 'yark',
121 fuzzy: { maxEdits: 1, maxExpansions: 100 }
122 }
123 }
124 }
125 ],
126 cursor: {},
127 '$db': 'sample_mflix'
128 },
129 ok: 1,
130 '$clusterTime': {
131 clusterTime: Timestamp({ t: 1758305729, i: 1 }),
132 signature: {
133 hash: Binary.createFromBase64('IUnIrXR/VeUrj1cGgyEFlkoQKAM=', 0),
134 keyId: Long('7551379485140975621')
135 }
136 },
137 operationTime: Timestamp({ t: 1758305729, i: 1 })
138}
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 <hostname>.mongodb.netmongotVersion: '1.42.0',
18 mongotHostName: '<hostname>.mongodb.net',
19 indexName: 'default',
20 totalLuceneDocs: 21349
21 }
22 },
23 requiresSearchMetaCursor: false
24 }
25 },
26 {
27 '$_internalSearchIdLookup': {
28 subPipeline: [
29 { '$match': { _id: { '$eq': '_id placeholder' } } }
30 ]
31 }
32 },
33 {
34 '$project': {
35 description: true,
36 highlights: { '$meta': 'searchHighlights' },
37 _id: false
38 }
39 }
40 ],
41 queryShapeHash: 'D08444272924C1E04A6E99D0CD4BF82FD929893862B3356F79EC18BBD1F0EF0C',
42 serverInfo: {
43 host: '<hostname>.mongodb.net',
44 port: 27017,
45 version: '8.2.0',
46 gitVersion: '13e629eeccd63f00d17568fc4c12b7530fa34b54'
47 },
48 serverParameters: {
49 ...
50 },
51 command: {
52 aggregate: 'movies',
53 pipeline: [
54 {
55 '$search': {
56 text: { path: 'title', query: 'prince' },
57 highlight: { path: 'title', maxNumPassages: 1, maxCharsToExamine: 40 }
58 }
59 },
60 {
61 '$project': {
62 description: 1,
63 _id: 0,
64 highlights: { '$meta': 'searchHighlights' }
65 }
66 }
67 ],
68 cursor: {},
69 '$db': 'sample_mflix'
70 },
71 ok: 1,
72 '$clusterTime': {
73 clusterTime: Timestamp({ t: 1758305809, i: 1 }),
74 signature: {
75 hash: Binary.createFromBase64('R7wN4/xS0eg0XFd23xeo/+hMPBY=', 0),
76 keyId: Long('7551379485140975621')
77 }
78 },
79 operationTime: Timestamp({ t: 1758305809, i: 1 })
80}
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 collectStats: {
28 facet: {
29 stringFacetCardinalities: { genresFacet: { queried: 10, total: 25 } }
30 }
31 },
32 metadata: {
33 <hostname>.mongodb.netmongotVersion: '1.42.0',
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.2.0',
48 gitVersion: '13e629eeccd63f00d17568fc4c12b7530fa34b54'
49 },
50 serverParameters: {
51 ...
52 },
53 command: {
54 aggregate: 'movies',
55 pipeline: [
56 {
57 '$searchMeta': {
58 facet: {
59 operator: {
60 near: {
61 path: 'released',
62 origin: ISODate('1921-11-01T00:00:00.000Z'),
63 pivot: 7776000000
64 }
65 },
66 facets: {
67 genresFacet: { type: 'string', path: 'genres' },
68 yearFacet: {
69 type: 'number',
70 path: 'year',
71 boundaries: [ 1910, 1920, 1930, 1940 ]
72 }
73 }
74 }
75 }
76 }
77 ],
78 cursor: {},
79 '$db': 'sample_mflix'
80 },
81 ok: 1,
82 '$clusterTime': {
83 clusterTime: Timestamp({ t: 1758305859, i: 1 }),
84 signature: {
85 hash: Binary.createFromBase64('8Zm16MEkzHnPpP9uLJK1YlT7a3o=', 0),
86 keyId: Long('7551379485140975621')
87 }
88 },
89 operationTime: Timestamp({ t: 1758305859, i: 1 })
90}

パイプラインで$limitステージを指定するクエリの場合、 explainの結果にはmongotDocsRequestedメトリクスが含まれます。これは、 mongodmongotからリクエストしたドキュメントの数を示します。

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

次の例では、autocomplete を使用して、title フィールドを executionStats 冗長モードでクエリします。

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: 12.517877,
36 invocationCounts: {
37 createWeight: Long('4'),
38 createScorer: Long('48')
39 }
40 },
41 match: {
42 millisElapsed: 0.970794,
43 invocationCounts: { nextDoc: Long('2436') }
44 },
45 score: {
46 millisElapsed: 0.638731,
47 invocationCounts: { score: Long('2420') }
48 }
49 }
50 }
51 ],
52 mustNot: [],
53 should: [
54 {
55 type: 'TermQuery',
56 args: { path: 'title', value: 'pre' },
57 stats: {
58 context: {
59 millisElapsed: 1.481341,
60 invocationCounts: {
61 createWeight: Long('4'),
62 createScorer: Long('16')
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: 15.118651,
76 invocationCounts: { createWeight: Long('4'), createScorer: Long('32') }
77 },
78 match: {
79 millisElapsed: 1.923822,
80 invocationCounts: { nextDoc: Long('2436') }
81 },
82 score: {
83 millisElapsed: 1.954216,
84 invocationCounts: { score: Long('2420') }
85 }
86 }
87 },
88 collectStats: {
89 allCollectorStats: {
90 millisElapsed: 4.189904,
91 invocationCounts: {
92 collect: Long('2420'),
93 competitiveIterator: Long('16'),
94 setScorer: Long('16')
95 }
96 },
97 facet: { collectorStats: { millisElapsed: 0 } }
98 },
99 resultMaterialization: {
100 stats: {
101 millisElapsed: 21.876621,
102 invocationCounts: { retrieveAndSerialize: Long('4') }
103 }
104 },
105 metadata: {
106 <hostname>.mongodb.netmongotVersion: '1.42.0',
107 mongotHostName: '<hostname>.mongodb.net',
108 indexName: 'default',
109 cursorOptions: { batchSize: 108, requiresSearchSequenceToken: false },
110 totalLuceneDocs: 21349
111 },
112 resourceUsage: {
113 majorFaults: Long('2'),
114 minorFaults: Long('242'),
115 userTimeMs: Long('40'),
116 systemTimeMs: Long('0'),
117 maxReportingThreads: 1,
118 numBatches: 4
119 }
120 },
121 requiresSearchMetaCursor: false,
122 internalMongotBatchSizeHistory: [ Long('108'), Long('162'), Long('243'), Long('365') ]
123 },
124 nReturned: Long('605'),
125 executionTimeMillisEstimate: Long('44')
126 },
127 {
128 '$_internalSearchIdLookup': {
129 subPipeline: [
130 { '$match': { _id: { '$eq': '_id placeholder' } } }
131 ],
132 totalDocsExamined: Long('605'),
133 totalKeysExamined: Long('605'),
134 numDocsFilteredByIdLookup: Long('0')
135 },
136 nReturned: Long('605'),
137 executionTimeMillisEstimate: Long('91')
138 }
139 ],
140 queryShapeHash: '6FD3791F785FA329D4ECD1171E0E5AF6772C18F5F0A7A50FC416D080A93C8CB7',
141 serverInfo: {
142 host: '<hostname>.mongodb.net',
143 port: 27017,
144 version: '8.2.0',
145 gitVersion: '13e629eeccd63f00d17568fc4c12b7530fa34b54'
146 },
147 serverParameters: {
148 ...
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: 1758306209, i: 1 }),
169 signature: {
170 hash: Binary.createFromBase64('MIipFR5NAfl728L6h4ueQeZBLGM=', 0),
171 keyId: Long('7551379485140975621')
172 }
173 },
174 operationTime: Timestamp({ t: 1758306209, i: 1 })
175}

explain 応答要素の詳細については、「Explain の結果」を参照してください。

項目一覧