MongoDB Search 쿼리는 explain 메서드가 활성화된 상태로 쿼리를 실행할 때 $search 쿼리 계획 및 실행 통계에 대한 정보를 반환합니다. explain(으)로 쿼리를 실행하면 MongoDB Search는 Lucene에서 쿼리가 내부적으로 어떻게 실행되었는지를 설명하는 통계 및 메타데이터가 포함된 BSON 문서를 반환합니다.
구문
db.<myCollection>.explain("<verbosity>").aggregate([ { $search: { "<operator>": { "<operator-options>" } } } ])
상세
상세 모드 explain 의 동작과 반환되는 정보의 양을 제어합니다. 값은 상세도가 낮은 순서대로 다음 중 하나일 수 있습니다.
쿼리에 대한 실행 쿼리 가 포함된 | |
쿼리에 대한 실행 통계가 포함된 | |
queryPlanner(기본값) | 쿼리 계획에 대한 정보입니다. 쿼리에 대한 실행 통계를 포함하는 |
출력
explain 메서드를 사용한 쿼리는 stages.$_internalSearchMongotRemote 객체에서 다음 필드를 반환합니다.
옵션 | 유형 | 목적 |
|---|---|---|
| 문서 | 실행한 쿼리를 포함합니다. |
| 문서 | Contains the |
| 정수 배열 | 각 배치의 문서 크기를 포함하여 |
결과 설명
explain 메서드는 explain 문서에 다음 필드가 포함된 BSON 문서를 반환합니다.
옵션 | 유형 | 필요성 | 목적 |
|---|---|---|---|
| 문서 | 옵션 | 수집기의 실행 통계를 설명합니다. |
| 문서 | 옵션 | |
| 문서 배열 | 옵션 | 인덱스 파티션별 세부 정보를 포함합니다. 두 개 이상의 인덱스 파티션을 구성한 경우에만 반환됩니다. |
| 문서 | 옵션 | 유용한 메타데이터를 포함합니다. |
| 문서 | 옵션 | 쿼리의 실행 통계를 설명합니다. 반환되지 않습니다. |
| 문서 | 옵션 | 쿼리 실행 후 Lucene에서 문서별 데이터를 검색하는 것과 관련된 세부 정보입니다. |
| 문서 | 옵션 | 쿼리가 실행되었을 때 쿼리의 리소스 사용량 세부 정보를 제공합니다. |
collectors
collectors BSON 문서에는 다음과 같은 필드가 있습니다.
필드 | 유형 | 필요성 | 목적 |
|---|---|---|---|
| 문서 | 필수 사항 | 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. |
| 문서 | 옵션 | |
| 문서 | 옵션 |
allCollectorStats
allCollectorStats BSON 문서는 쿼리에 지정된 모든 수집기의 수집기 통계를 facet 및 sort을(를) 포함하여 설명합니다. 다음과 같은 키가 포함되어 있습니다.
필드 | 설명 |
|---|---|
| 수집기가 수집한 결과의 지속 시간과 수량을 추적합니다. |
| 수집기에서 |
| 수집기에 설정된 점수 계산기의 총 지속 시간과 횟수를 추적하는 통계입니다. |
facet
facet은 쿼리에서 패싯을 지정할 때 쿼리 및 실행 통계를 상세히 설명하는 BSON 문서입니다. 다음 필드를 포함합니다.
옵션 | 유형 | 필요성 | 목적 |
|---|---|---|---|
| 문서 | 옵션 |
|
| 문서 | 옵션 | 모든 패싯 그룹을 보유하는 내부 Lucene 객체 생성과 관련된 통계를 표시합니다. |
| 문서 | 필수 사항 | 쿼리와 일치하는 문서 및 전체 Lucene 인덱스에 대해 패싯 처리된 필드를 해당 카디널리티에 매핑합니다. 각 필드에 대해 다음과 같은 카디널리티 정보를 제공합니다.
|
sort
sort는 쿼리에서 정렬을 지정할 때 쿼리 및 실행 통계를 상세히 설명하는 BSON 문서입니다. 다음 필드를 포함합니다.
옵션 | 유형 | 필요성 | 목적 |
|---|---|---|---|
| 문서 | 옵션 | 모든 정렬 필드에서
|
| 문서 | 필수 사항 | 정렬되는 필드를 해당 필드의 인덱스에 존재하는 데이터 유형 목록에 매핑합니다. |
| 부울 | 옵션 | 쿼리가 인덱스 정렬의 이점을 받을 수 있는지 여부를 나타냅니다. 쿼리의 정렬 필드가 인덱스 정렬과 일치하거나 인덱스 정렬의 접두어를 형성하는 경우 쿼리가 이점을 받습니다. 값이 다음과 같은 경우:
쿼리에 정렬이 지정되지 않거나 인덱스에 정렬 사양이 없는 경우 출력에 이것이 없습니다. |
highlight
highlight는 쿼리에 강조 표시를 지정할 때 쿼리 및 실행 통계를 자세히 설명하는 BSON 문서입니다. 다음 필드를 포함합니다.
옵션 | 유형 | 필요성 | 목적 |
|---|---|---|---|
| List<String> | 필수 사항 | 강조 표시된 모든 필드의 목록입니다. 쿼리의 |
| QueryExecutionArea | 옵션 | 강조 표시 설정 및 실행과 관련된 호출 및 타이밍 통계입니다. 다음 필드를 포함합니다.
|
indexPartitionExplain
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.
metadata
metadata는 다음과 같은 유용한 메타데이터를 포함합니다.
필드 | 유형 | 필요성 | 목적 |
|---|---|---|---|
| 문자열 | 옵션 |
|
| 문자열 | 옵션 |
|
| 문자열 | 옵션 | 쿼리 에 사용된 MongoDB Search 인덱스 . |
| 문서 | 옵션 |
|
| Integer | 옵션 | 삭제된 문서를 포함한 인덱스 내 전체 객체 수입니다. |
query
query BSON 문서는 쿼리 실행 통계를 설명합니다. 다음 필드를 포함합니다.
필드 | 유형 | 필요성 | 목적 |
|---|---|---|---|
| 문자열 | 옵션 | 연산자의 경로(루트가 아닌 경우에만). |
| 문자열 | 필수 사항 | MongoDB Search 연산자 생성한 루센 쿼리의 이름입니다. 자세한 내용은 |
| 문자열 | 옵션 | 쿼리 와 함께 사용되는 MongoDB Search 분석기 . |
| 문서 | 필수 사항 | Lucene 쿼리 정보입니다. 자세한 내용은 |
| 문서 | 옵션 |
|
args
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 MongoDB Search executed to satisfy a $search query.
이 섹션에는 다음이 포함됩니다.
MongoDB Search 연산자가 생성하는 일부 루센 쿼리
구조화된 요약에 포함된 루센 쿼리 옵션
각 루센 쿼리 유형에 대한 루센 쿼리 구조화된 요약 예시
참고
예시 정보
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필드 MongoDB Search 연산자 와 실행 된 쿼리 표시됩니다.explain.type필드에는 연산자가 만든 루센 쿼리가 표시됩니다.
전체 예시를 보려면 예시를 참조하세요.
BooleanQuery루센
BooleanQuery의 경우 구조화된 요약에 다음 옵션에 대한 세부 정보가 포함되어 있습니다.필드유형필요성설명must옵션
일치해야 하는 절입니다.
mustNot옵션
일치해서는 안 되는 절.
should옵션
일치해야 하는 절입니다.
filter옵션
모두 일치해야 하는 절.
minimumShouldMatchInteger
옵션
일치해야 하는
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루센
FunctionScoreQuery쿼리의 경우 구조화된 요약에 다음 옵션에 대한 세부 정보가 포함되어 있습니다.필드유형필요성설명scoreFunction문자열
필수 사항
쿼리에 사용된 점수 표현식입니다.
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 }
LatLonPointDistanceQueryFor Lucene
LatLonPointDistanceQueryqueries, the response contains anstatsonly.다음 예제에서는
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 }
LatLonShapeQueryFor Lucene
LatLonShapeQueryqueries, the response contains anstatsonly.다음 예제에서는
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 }
LongDistanceFeatureQueryFor Lucene
LongDistanceFeatureQuery, the response contains anstatsonly.다음 예제에서는
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루센
MultiTermQueryConstantScoreWrapper쿼리의 경우 구조화된 요약에는 다음 인수에 대한 세부 정보가 포함되어 있습니다.필드유형필요성설명queriesList<Explain Results>
필수 사항
쿼리 목록.
다음 예제에서는
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루센
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루센
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문자열
필수 사항
검색할 문자열입니다.
다음 예제에서는
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다른 루센 쿼리에서 명시적으로 정의되지 않은 루센 쿼리는 기본 쿼리를 사용하여 직렬화됩니다. 구조화된 요약에는 다음 옵션에 대한 세부 정보가 포함되어 있습니다.
필드유형필요성설명queryType문자열
필수 사항입니다.
루씬 쿼리 유형.
다음 예제에서는
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 }
stats
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.
타이밍 분석
타이밍 분석은 쿼리 실행 영역 과 관련된 실행 통계를 설명합니다. 다음 필드에는 타이밍 분석이 표시됩니다.
쿼리 영역
다음 쿼리 영역에 대한 통계를 사용할 수 있습니다.
옵션 | 설명 | |||||||
|---|---|---|---|---|---|---|---|---|
| Lucene 쿼리 실행과 관련된 통계입니다. 이 영역에서 호출 횟수가 열거되는 두 가지 작업이 있습니다.
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. 예를 들면 다음과 같습니다. | |||||||
| 결과 문서를 반복하고 일치시키는 것과 관련된 통계입니다. 이 통계는 어떤 문서가 다음 일치 항목인지 결정하는 데 걸리는 시간을 보여줍니다. 결과 일치에 소요되는 시간은 쿼리의 특성에 따라 크게 달라질 수 있습니다. 이 영역에서 호출 횟수가 열거되는 두 가지 작업이 있습니다.
예를 들면 다음과 같습니다. | |||||||
| 결과 세트의 문서 점수 산정과 관련된 통계입니다. 이 영역에서 호출 횟수가 열거되는 두 가지 작업이 있습니다.
예를 들면 다음과 같습니다. |
resultMaterialization
resultMaterialization 문서는 mongot가 다음 작업을 수행하는 데 걸리는 시간을 보여줍니다.
Lucene에 저장된 결과 데이터를
_id또는storedSource형태로 검색합니다.mongod에 보내기 전에 데이터를 BSON 형식으로 직렬화합니다.
To learn more, see stats.
resourceUsage
resourceUsage 문서는 쿼리 실행에 사용된 리소스를 보여줍니다. 다음 필드를 포함합니다.
필드 | 유형 | 필요성 | 목적 |
|---|---|---|---|
| Long | 필수 사항 | 쿼리 실행 중 시스템이 메모리에서 필요한 데이터를 찾지 못해 디스크와 같은 백업 저장소에서 읽게 될 때 발생하는 주요 페이지 폴트 수입니다. |
| Long | 필수 사항 | 데이터가 페이지 캐시에 있지만 아직 프로세스의 페이지 테이블에 매핑되지 않은 경우 발생하는 경미한 페이지 폴트의 수입니다. |
| Long | 필수 사항 | 사용자 공간에서 소요된 CPU 시간(밀리초)입니다. |
| Long | 필수 사항 | 시스템 공간에서 소요된 CPU 시간(단위: 밀리초)입니다. |
| Integer | 필수 사항 | 모든 배치에서 쿼리 실행 중 |
| Integer | 필수 사항 | 쿼리 처리 시 요청된 |
예시
다음 예시에서는 sample_mflix 데이터베이스의 movies 컬렉션을 사용합니다.
팁
If you've already loaded the sample dataset, refer to the MongoDB Search Quick Start tutorial to create an index definition and run MongoDB Search queries.
allPlansExecution
다음 예시에서는 다양한 연산자를 사용하여 allPlansExecution 상세 수준 모드로 title 필드를 쿼리합니다.
db.movies.explain("allPlansExecution").aggregate([ { $search: { "text": { "path": "title", "query": "yark", "fuzzy": { "maxEdits": 1, "maxExpansions": 100, } } } } ])
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" } } } ])
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] } } } } } ])
db.movies.explain("allPlansExecution").aggregate([ { $search: { "text": { "path": "title", "query": "yark", "fuzzy": { "maxEdits": 1, "maxExpansions": 100, } } } } ])
queryPlanner
다음 예시에서는 다양한 연산자를 사용하여 queryPlanner 상세 수준 모드로 title 필드를 쿼리합니다.
db.movies.explain("queryPlanner").aggregate([ { $search: { "text": { "path": "title", "query": "yark", "fuzzy": { "maxEdits": 1, "maxExpansions": 100, } } } } ])
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" } } } ])
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] } } } } } ])
db.movies.explain("queryPlanner").aggregate([ { $search: { index: "default", range: { path: "released", gt: ISODate("2015-01-01T00:00:00.000Z"), lt: ISODate("2015-12-31T00:00:00.000Z") }, sort: { released: -1 } } }, { $limit: 5 }, { $project: { _id: 0, title: 1, released: 1 } } ])
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.
예시
{ "mongotQuery": {}, "explain": {}, "limit": <int>, "sortSpec": {}, "mongotDocsRequested": <int>, }
executionStats
The following example uses the autocomplete to query the title field with the executionStats verbosity mode.
1 db.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 ])
explain 응답 요소에 대한 자세한 내용은 Explain 결과를 참조하세요.