Docs Menu
Docs Home
/
MongoDB Atlas
/ / /

Lucene クエリ構造の概要

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

このページには、次の内容が含まれています。

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

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

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

注意

例について

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

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

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

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

BooleanQuery

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

フィールド
タイプ
必要性
説明
must
任意
一致する必要がある句。
mustNot
任意
一致してはならない句。
should
任意
一致する必要がある句。
filter
任意
すべて一致する必要がある句。
minimumShouldMatch
整数
任意
一致する必要があるshould句の最小数。

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

1{
2 "stages" : [
3 {
4 "$_internalSearchMongotRemote" : {
5 "mongotQuery" : {
6 "compound" : {
7 "must" : [ {
8 "compound" : {
9 "should" : [ {
10 "text" : {
11 "query" : "historic",
12 "path" : "summary"
13 }
14 },
15 {
16 "text" : {
17 "query" : "Portugal",
18 "path" : "address.country"
19 }
20 },
21 {
22 "text" : {
23 "query" : "railway",
24 "path" : "transit"
25 }
26 } ]
27 }
28 } ],
29 "mustNot" : [ {
30 "text" : {
31 "query" : "Apartment",
32 "path" : "property_type"
33 }
34 } ]
35 }
36 },
37 "explain" : {
38 "type" : "BooleanQuery",
39 "args" : {
40 "must" : [ {
41 "path" : "compound.must",
42 "type" : "BooleanQuery",
43 "args" : {
44 "must" : [ ],
45 "mustNot" : [ ],
46 "should" : [
47 {
48 "path" : "compound.must.compound.should[0]",
49 "type" : "TermQuery",
50 "args" : {
51 "path" : "summary",
52 "value" : "historic"
53 }
54 },
55 {
56 "path" : "compound.must.compound.should[1]",
57 "type" : "TermQuery",
58 "args" : {
59 "path" : "address.country",
60 "value" : "portugal"
61 }
62 },
63 {
64 "path" : "compound.must.compound.should[2]",
65 "type" : "TermQuery",
66 "args" : {
67 "path" : "transit",
68 "value" : "railway"
69 }
70 }
71 ],
72 "filter" : [ ],
73 "minimumShouldMatch" : 0
74 }
75 } ],
76 "mustNot" : [ {
77 "path" : "compound.mustNot",
78 "type" : "TermQuery",
79 "args" : {
80 "path" : "property_type",
81 "value" : "apartment"
82 }
83 } ],
84 "should" : [ ],
85 "filter" : [ ],
86 "minimumShouldMatch" : 0
87 }
88 }
89 },
90 ...
91 },
92 ...
93 ],
94 ...
95}
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クエリの場合、レスポンスには説明タイミングの内訳のみが含まれます。

次の例では、 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クエリの場合、レスポンスには説明タイミングの内訳のみが含まれます。

次の例では、 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の場合、レスポンスには説明タイミングの内訳のみが含まれます。

次の例では、 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
string
必須
検索するインデックス付きフィールド。
query
string
必須
検索する文字列または複数の文字列。
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
string
必須
検索するインデックス付きフィールド。
representation
string
任意
数値表現。 日付型データに対するクエリには表現は含まれません。
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
string
必須
検索するインデックス付きフィールド。
value
string
必須
検索する 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
string
必須。
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}