Docs 菜单

检索查询计划和执行统计信息

在使用 explain 方法运行查询时,Atlas Search 查询返回有关 $search 查询计划和执行统计信息的信息。当您使用 explain 运行查询时,Atlas Search 会返回一个 BSON 文档,其中包含统计信息和元数据,描述查询在 Lucene 内部的运行方式。

另请参阅:

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

详细模式控制 explain 的行为和返回的信息量。值可以是以下之一,按详细程度降序排列:

有关查询计划的信息,包括 stats 字段,其中包含查询的执行统计信息。包括在计划选择期间捕获的部分执行数据。

有关查询计划的信息,包括 stats 字段,其中包含查询的执行统计信息。

queryPlanner(默认)

有关查询计划的信息。不包括 stats 字段,其中包含查询的执行统计信息。

另请参阅:

explain 方法返回包含以下字段的BSON文档。

选项
类型
必要性
用途

collectors

文档

Optional

描述收集器的执行统计信息。如果 indexPartitionExplain 存在,它将嵌套在每个 indexPartitionExplain 中,而不是在顶层。

highlight

文档

Optional

关于突出显示查询执行的详细信息。仅当您在查询中指定突出显示时,才会返回此值。

indexPartitionExplain

文档数组

Optional

包含每个索引分区的详细信息。仅当您配置了两个或多个索引分区时,才会返回此信息。

metadata

文档

Optional

包含有用的元数据。

query

文档

Optional

描述查询的执行统计信息。如果 indexPartitionExplain 存在,则不是这样,它嵌套在每个 indexPartitionExplain 中,而不是在顶层。

resultMaterialization

文档

Optional

有关在查询执行后从 Lucene 检索每个文档数据的详细信息。对于 queryPlanner 详细模式,不会返回此值。

resourceUsage

文档

Optional

详细说明执行查询时的资源使用情况。对于 queryPlanner 详细模式,不会返回此值。

collectors BSON 文档包含以下字段:

字段
类型
必要性
用途

allCollectorStats

文档

必需

查询的所有收集器的统计信息。报告的统计信息表示查询中使用的所有收集器的最大值或所有子收集器的统计信息总和。计时统计信息相加求和,以反映整个查询中所有收集器所花费的总时间。要学习;了解详情,请参阅 allCollectorStats

facet

文档

Optional

指定分面的查询的明细。要了解更多信息,请参阅 facet

sort

文档

Optional

指定排序的查询明细。要了解更多信息,请参阅 sort

allCollectorStats BSON 文档描述了查询中指定的所有收集器的统计信息,包括 facetsort。它包含以下键:

字段
说明

collect

追踪收集器收集的结果数量和持续时间。

competitiveIterator

统计信息跟踪从收集器请求 competitiveIterator 的总持续时间和次数。

setScorer

统计信息跟踪在收集器上设置记分器的总持续时间和次数。

facet 是一个 BSON 文档,当您在查询中指定分面时,该文档会详细说明查询和执行统计信息。它包含以下字段:

选项
类型
必要性
用途

collectorStats

文档

Optional

仅显示 facet 收集器的统计信息。这里的密钥与 allCollectorStats 是相同的。如果您在查询中使用了 sort,您可以评估它与 allCollectorStats 之间的差异,以确定 sort 收集器执行统计信息。

createCountsStats

文档

Optional

显示与创建内部 Lucene 对象相关的统计信息,该对象包含所有分面分组。它包含 generateFacetCounts 字段,该字段返回统计信息,跟踪 mongot 生成 Lucene 对象的总持续时间和次数,该对象包含所有分面及其计数。

stringFacetFieldCardinalities

文档

必需

对于与查询匹配的文档和整个 Lucene 索引,将分面字段映射到其关联基数。它为每个字段提供以下关联基数信息:

  • queried - 表示跨所有查询文档的字段的分面关联基数。

  • total - 表示跨索引中所有文档的字段的分面关联基数。

sort 是一个 BSON 文档,详细说明了在查询中指定排序时的查询和执行统计信息。它包含以下字段:

选项
类型
必要性
用途

stats

文档

Optional

追踪与sort执行相关的统计信息,涵盖所有排序字段。它包含以下字段:

  • comparator-显示有关 Lucene 如何对结果进行排序的统计信息和元数据。

    • setBottom - 返回当前竞争力最弱的排序值被更新为更具竞争力的新值的频率。在排序时,Atlas Search 会追踪最低值,如果新值在相关性或竞争力方面超过当前的最低值,则该指标会增加。

    • compareBottom - 返回与当前 bottom 值与候选 bottom 值比较相关的时间和调用统计信息。

    • compareTop - 返回与当前 top 值与候选 top 值比较相关的时间和调用统计信息。

    • setHitsThresholdReached — 返回与何时达到最大结果数 (limit) 相关的计时和调用统计信息。

    • competitiveIterator -(仅)返回与可能争夺排序结果中最高位置的文档进行迭代相关的计时和调用统计信息。

    • setScorer - 返回与计算文档分数和相关性相关的计时和调用统计信息。

  • prunedResultIterator - 显示 Lucene 的 competitiveIteratornextDocadvance 方法调用的调用和计时统计信息。

    如果执行混合数据类型排序,输出中不会出现此内容。

    它仅包含 nextDoc 字段。

fieldInfos

文档

必需

将正在排序的字段映射到该字段索引中的数据类型列表。

highlight是一个BSON文档,当您在查询中指定突出显示时,它详细说明了查询和执行统计信息。它包含以下字段:

选项
类型
必要性
用途

resolvedHighlightPaths

列表<String>

必需

所有高亮字段的列表。如果您在查询的 highlight 部分指定了通配符路径,则会包含一个完全解析的文档路径列表。

stats

QueryExecutionArea

Optional

与设置和执行突出显示相关的调用和计时统计信息。它包含以下字段:

  • setupHighlight - 设置 executeHighlight 阶段使用的内部 Lucene 对象所花费的时间。

  • executeHighlight - 运行高亮显示匹配文档所需的时间。

indexPartitionExplain 包含每个索引分区的解释结果。顶层 collectorsquery 位于每个索引分区的 explain 信息中,而不在顶层。

metadata 包含有用的元数据,例如:

字段
类型
必要性
用途

mongotVersion

字符串

Optional

mongot 的当前版本。

mongotHostName

字符串

Optional

用于标识 mongot 主机的人类可读标签。

indexName

字符串

Optional

查询中使用的 Atlas Search 索引。

cursorOptions

文档

Optional

mongot 提供的游标选项。

totalLuceneDocs

整型

Optional

索引中包括已删除文档的索引对象总数。

queryBSON文档描述了查询的执行统计信息。它包含以下字段:

字段
类型
必要性
用途

path

字符串

Optional

操作符的路径,前提是它不是根目录。

type

字符串

必需

Atlas Search 操作符创建的 Lucene 查询的名称。有关更多信息,请参阅 query

analyzer

字符串

Optional

用于查询的 Atlas Search 分析器

args

文档

必需

Lucene 查询信息。有关更多信息,请参阅 query

stats

文档

Optional

搜索命令的解释响应包含与该命令执行的查询相关的信息。args 字段中的响应包括 Lucene 查询 Atlas Search 为满足 $search 查询而执行的查询的结构化详细信息。

本节包含:

  • Atlas Search 操作符创建的一些 Lucene 查询

  • 结构化摘要中包含的 Lucene 查询选项

  • 每个 Lucene 查询类型的 Lucene 查询结构化摘要示例

注意

关于示例

本节中的示例来自于对于具有 queryPlanner详细模式示例数据库运行的查询。在本示例响应中:

  • mongotQuery 字段显示 Atlas Search 操作符和运行的查询。

  • explain.type 字段显示操作符创建的 Lucene 查询。

有关完整示例,请参阅示例

BooleanQuery

对于 Lucene BooleanQuery,结构化摘要包含有关以下选项的详细信息:

字段
类型
必要性
说明

must

Optional

必须匹配的条款。

mustNot

Optional

不得匹配的子句。

should

Optional

应匹配的子句。

filter

Optional

必须全部匹配的子句。

minimumShouldMatch

整型

Optional

必须匹配的最小 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

字符串

必需

查询中使用的评分表达式。

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

字符串

Optional

数字表示形式。对日期类型数据的查询不包括表示形式。

gte

数值

Optional

查询的下限。

lte

数值

Optional

查询的上限。

以下示例显示了针对 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

未由其他 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 查询执行相关的统计信息。 此区域中枚举了两个任务的调用计数:

createScorer

评分器遍历文档并为每个文档生成分数。 调用createScorer会创建负责评分的对象。 请注意,与此任务相关的时间不是实际对文档进行评分所花费的时间。 计数包括scorerSupplier调用次数。

createWeight

权重存储与查询和IndexSearcher关联的状态。 计数包括createWeight调用次数。

此区域花费的时间与查询的结构有关,而不是基于迭代和评分的结果数量。

例如:

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

match

与遍历和匹配结果文档相关的统计信息。 此统计信息显示确定下一个匹配的文档所需的时间。 根据查询的性质,匹配结果所花费的时间可能会有很大差异。 此区域中枚举了两个任务的调用计数:

nextDoc

请求前进到结果集的下一个文档。 这涉及识别并移动过去的跳过,或查找下一个匹配项所需的其他任务。 计数包括nextDocadvance调用的次数。

refineRoughMatch

执行更彻底的匹配。 某些查询以双阶段过程执行,其中首先对文档进行“粗略”匹配,仅在满足第一次粗略匹配后才使用第二个更彻底的阶段进行检查。 refineRoughMatch任务是双阶段进程的第二阶段。 计数包括refineRoughMatch调用次数。

例如:

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

score

与结果集中的文档评分相关的统计信息。 此区域中枚举了两个任务的调用计数:

score

对结果集中的每个文档进行评分。 计数包括score调用次数。

setMinCompetitiveScore

忽略分数低于给定值的文档。 表示查询也许能够通过忽略分数低于某个非竞争阈值的文档来减少执行的评分操作数。 计数包括setMinCompetitiveScore调用次数。

例如:

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

resultMaterialization 文档显示 mongot 完成以下任务所需的时间:

  1. 检索以 _idstoredSource 形式存储在 Lucene 中的结果数据。

  2. 将数据序列化为 BSON 格式,然后发送到 mongod

要了解更多信息,请参阅 stats

resourceUsage 文档显示了用于运行查询的资源。它包含以下字段:

字段
类型
必要性
用途

majorFaults

Long

必需

主要页面错误的数量,当系统在查询执行期间无法在内存中找到所需数据,导致从磁盘等后备存储中读取数据时,就会发生这种错误。

minorFaults

Long

必需

次要页面错误的数量,当数据在页面缓存中,但尚未映射到进程的页表时发生。

userTimeMs

Long

必需

在用户空间中花费的 CPU 时间,以毫秒为单位。

systemTimeMs

Long

必需

在系统空间中花费的 CPU 时间,以毫秒为单位。

maxReportingThreads

整型

必需

在所有批处理中执行查询期间,mongot 使用的最大线程数。对于非并发解释查询,值为 1

numBatches

整型

必需

处理查询时请求 mongot 的批处理总数。

以下示例使用 sample_mflix 数据库中的 movies 集合。

提示

如果您已经加载示例数据集,请按照 Atlas Search 入门教程,创建索引定义并运行 Atlas Search 查询。

以下示例使用不同的操作符以 allPlansExecution 详细模式查询 title 字段。

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}

以下示例使用不同的操作符以 queryPlanner 详细模式查询 title 字段。

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}

对于在管道中指定$limit阶段的查询, explain结果包括mongotDocsRequested指标,该指标显示mongodmongot请求的文档数。

例子

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

以下示例使用 autocomplete 操作符以 executionStats 详细程度模式查询 title 字段。

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}

要了解有关 explain 响应元素的更多信息,请参阅解释结果