Profile
1.0 版本引入Profile API 提供有关搜索请求各个组件执行的时间信息。使用 Profile API,你可以调试慢查询并了解如何提高其性能。Profile API 不测量以下内容:
- 网络延迟
- 搜索获取阶段花费的时间
- 请求在队列中花费的时间
- 在协调节点上合并分片响应时的空闲时间
WARNING
Profile API 是一种资源消耗型操作,会给搜索操作增加开销。
并发段搜索
从 OpenSearch 2.12 开始,并发段搜索允许每个分片级请求在查询阶段并行搜索段。Profile API 响应包含几个关于_切片_统计信息的附加字段。
切片是可由线程执行的工作单元。每个查询可以分成多个切片,每个切片包含一个或多个段。所有切片可以并行执行或按某种顺序执行,具体取决于池中的可用线程。
通常,max/min/avg 切片时间捕获某个时间类型的所有切片统计信息。例如,在分析聚合时,aggregations 部分中的 max_slice_time_in_nanos 字段显示聚合操作及其所有切片的子操作消耗的最大时间。
示例请求:非并发搜索
要使用 Profile API,请在发送到 _search 端点的搜索请求中包含设置为 true 的 profile 参数:
GET /testindex/_search
{
"profile": true,
"query" : {
"match" : { "title" : "wind" }
}
}要开启人类可读格式,请在请求中包含 ?human=true 查询参数:
GET /testindex/_search?human=true
{
"profile": true,
"query" : {
"match" : { "title" : "wind" }
}
}响应包含一个带有人类可读单位的附加 time 字段,例如:
"collector": [
{
"name": "SimpleTopScoreDocCollector",
"reason": "search_top_hits",
"time": "113.7micros",
"time_in_nanos": 113711
}
]TIP
Profile API 响应非常详细,因此如果你通过 curl 命令运行请求,请包含 ?pretty 查询参数以使响应更易于理解。
示例响应
响应包含分析信息:
响应
{
"took": 21,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 0.19363807,
"hits": [
{
"_index": "testindex",
"_id": "1",
"_score": 0.19363807,
"_source": {
"title": "The wind rises"
}
},
{
"_index": "testindex",
"_id": "2",
"_score": 0.17225474,
"_source": {
"title": "Gone with the wind",
"description": "A 1939 American epic historical film"
}
}
]
},
"profile": {
"shards": [
{
"id": "[LidyZ1HVS-u93-73Z49dQg][testindex][0]",
"inbound_network_time_in_millis": 0,
"outbound_network_time_in_millis": 0,
"searches": [
{
"query": [
{
"type": "BooleanQuery",
"description": "title:wind title:rise",
"time_in_nanos": 2473919,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 5209,
"match": 0,
"next_doc_count": 2,
"score_count": 2,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 9209,
"advance_count": 2,
"score": 20751,
"build_scorer_count": 4,
"create_weight": 1404458,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 1034292
},
"children": [
{
"type": "TermQuery",
"description": "title:wind",
"time_in_nanos": 813581,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 3291,
"match": 0,
"next_doc_count": 2,
"score_count": 2,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 7208,
"advance_count": 2,
"score": 18666,
"build_scorer_count": 6,
"create_weight": 616375,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 168041
}
},
{
"type": "TermQuery",
"description": "title:rise",
"time_in_nanos": 191083,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 0,
"match": 0,
"next_doc_count": 0,
"score_count": 0,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 0,
"advance_count": 0,
"score": 0,
"build_scorer_count": 2,
"create_weight": 188625,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 2458
}
}
]
}
],
"rewrite_time": 192417,
"collector": [
{
"name": "SimpleTopScoreDocCollector",
"reason": "search_top_hits",
"time_in_nanos": 77291
}
]
}
],
"aggregations": []
}
]
}
}示例响应:并发段搜索
以下是具有三个段切片的并发段搜索的示例响应:
响应
{
"took": 10,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 5,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
...
]
},
"aggregations": {
...
},
"profile": {
"shards": [
{
"id": "[9Y7lbpaWRhyr5Y-41Zl48g][idx][0]",
"inbound_network_time_in_millis": 0,
"outbound_network_time_in_millis": 0,
"searches": [
{
"query": [
{
"type": "MatchAllDocsQuery",
"description": "*:*",
"time_in_nanos": 868000,
"max_slice_time_in_nanos": 19376,
"min_slice_time_in_nanos": 12250,
"avg_slice_time_in_nanos": 16847,
"breakdown": {
"max_match": 0,
"set_min_competitive_score_count": 0,
"match_count": 0,
"avg_score_count": 1,
"shallow_advance_count": 0,
"next_doc": 29708,
"min_build_scorer": 3125,
"score_count": 5,
"compute_max_score_count": 0,
"advance": 0,
"min_set_min_competitive_score": 0,
"min_advance": 0,
"score": 29250,
"avg_set_min_competitive_score_count": 0,
"min_match_count": 0,
"avg_score": 333,
"max_next_doc_count": 3,
"max_compute_max_score_count": 0,
"avg_shallow_advance": 0,
"max_shallow_advance_count": 0,
"set_min_competitive_score": 0,
"min_build_scorer_count": 2,
"next_doc_count": 8,
"min_match": 0,
"avg_next_doc": 888,
"compute_max_score": 0,
"min_set_min_competitive_score_count": 0,
"max_build_scorer": 5791,
"avg_match_count": 0,
"avg_advance": 0,
"build_scorer_count": 6,
"avg_build_scorer_count": 2,
"min_next_doc_count": 2,
"min_shallow_advance_count": 0,
"max_score_count": 2,
"avg_match": 0,
"avg_compute_max_score": 0,
"max_advance": 0,
"avg_shallow_advance_count": 0,
"avg_set_min_competitive_score": 0,
"avg_compute_max_score_count": 0,
"avg_build_scorer": 4027,
"max_set_min_competitive_score_count": 0,
"advance_count": 0,
"max_build_scorer_count": 2,
"shallow_advance": 0,
"min_compute_max_score": 0,
"max_match_count": 0,
"create_weight_count": 1,
"build_scorer": 32459,
"max_set_min_competitive_score": 0,
"max_compute_max_score": 0,
"min_shallow_advance": 0,
"match": 0,
"max_shallow_advance": 0,
"avg_advance_count": 0,
"min_next_doc": 708,
"max_advance_count": 0,
"min_score": 291,
"max_next_doc": 999,
"create_weight": 1834,
"avg_next_doc_count": 2,
"max_score": 376,
"min_compute_max_score_count": 0,
"min_score_count": 1,
"min_advance_count": 0
}
}
],
"rewrite_time": 8126,
"collector": [
{
"name": "QueryCollectorManager",
"reason": "search_multi",
"time_in_nanos": 564708,
"reduce_time_in_nanos": 1251042,
"max_slice_time_in_nanos": 121959,
"min_slice_time_in_nanos": 28958,
"avg_slice_time_in_nanos": 83208,
"slice_count": 3,
"children": [
{
"name": "SimpleTopDocsCollectorManager",
"reason": "search_top_hits",
"time_in_nanos": 500459,
"reduce_time_in_nanos": 840125,
"max_slice_time_in_nanos": 22168,
"min_slice_time_in_nanos": 5792,
"avg_slice_time_in_nanos": 12084,
"slice_count": 3
},
{
"name": "NonGlobalAggCollectorManager: [histo]",
"reason": "aggregation",
"time_in_nanos": 552167,
"reduce_time_in_nanos": 311292,
"max_slice_time_in_nanos": 95333,
"min_slice_time_in_nanos": 18416,
"avg_slice_time_in_nanos": 66249,
"slice_count": 3
}
]
}
]
}
],
"aggregations": [
{
"type": "NumericHistogramAggregator",
"description": "histo",
"time_in_nanos": 2847834,
"max_slice_time_in_nanos": 117374,
"min_slice_time_in_nanos": 20624,
"avg_slice_time_in_nanos": 75597,
"breakdown": {
"min_build_leaf_collector": 9500,
"build_aggregation_count": 3,
"post_collection": 3209,
"max_collect_count": 2,
"initialize_count": 3,
"reduce_count": 0,
"avg_collect": 17055,
"max_build_aggregation": 26000,
"avg_collect_count": 1,
"max_build_leaf_collector": 64833,
"min_build_leaf_collector_count": 1,
"build_aggregation": 41125,
"min_initialize": 583,
"max_reduce": 0,
"build_leaf_collector_count": 3,
"avg_reduce": 0,
"min_collect_count": 1,
"avg_build_leaf_collector_count": 1,
"avg_build_leaf_collector": 45000,
"max_collect": 24625,
"reduce": 0,
"avg_build_aggregation": 12013,
"min_post_collection": 292,
"max_initialize": 1333,
"max_post_collection": 750,
"collect_count": 5,
"avg_post_collection": 541,
"avg_initialize": 986,
"post_collection_count": 3,
"build_leaf_collector": 86833,
"min_collect": 6250,
"min_build_aggregation": 3541,
"initialize": 2786791,
"max_build_leaf_collector_count": 1,
"min_reduce": 0,
"collect": 29834
},
"debug": {
"total_buckets": 1
}
}
]
}
]
}
}响应字段
响应包括以下字段。
| 字段 | 数据类型 | 描述 |
|---|---|---|
profile | Object | 包含分析信息。 |
profile.shards | 对象数组 | 搜索请求可以针对索引中的一个或多个分片执行,搜索可能涉及一个或多个索引。因此,profile.shards 数组包含参与搜索的每个分片的分析信息。 |
profile.shards.id | String | 分片 ID,格式为 [node-ID][index-name][shard-ID]。 |
profile.shards.searches | 对象数组 | 搜索表示针对底层 Lucene 索引执行的查询。大多数搜索请求针对 Lucene 索引执行单个搜索,但某些搜索请求可以执行多个搜索。例如,包含全局聚合会导致为全局上下文执行辅助的 match_all 查询。profile.shards 数组包含每个搜索执行的分析信息。 |
profile.shards.searches.query | 对象数组 | 有关查询执行的分析信息。 |
profile.shards.searches.rewrite_time | Integer | 所有 Lucene 查询都会被重写。查询及其子查询可能会被多次重写,直到查询停止更改。重写过程涉及执行优化,例如删除冗余子句或用更高效的路径替换查询路径。重写过程后,原始查询可能会发生重大变化。rewrite_time 字段包含查询及其所有子查询的累计总重写时间,以纳秒为单位。 |
profile.shards.searches.collector | 对象数组 | 有关运行搜索的 Lucene 收集器的分析信息。 |
profile.shards.aggregations | 对象数组 | 有关聚合执行的分析信息。 |
query 数组
query 数组包含具有以下字段的对象。
| 字段 | 数据类型 | 描述 |
|---|---|---|
type | String | 搜索查询被重写成的 Lucene 查询类型。对应于 Lucene 类名(在 OpenSearch 中通常具有相同的名称)。 |
description | String | 包含查询的 Lucene 解释。有助于区分具有相同类型的查询。 |
time_in_nanos | Long | 此查询的总耗时,以纳秒为单位。对于并发段搜索,time_in_nanos 是所有切片的总时间(最后完成的切片执行结束时间与第一个切片执行开始时间之差)。 |
max_slice_time_in_nanos | Long | 任何切片运行查询所花费的最大时间,以纳秒为单位。仅在启用并发段搜索时包含此字段。 |
min_slice_time_in_nanos | Long | 任何切片运行查询所花费的最小时间,以纳秒为单位。仅在启用并发段搜索时包含此字段。 |
avg_slice_time_in_nanos | Long | 任何切片运行查询所花费的平均时间,以纳秒为单位。仅在启用并发段搜索时包含此字段。 |
breakdown | Object | 包含有关低级 Lucene 执行的时间统计信息。 |
children | 对象数组 | 如果查询具有子查询(children),此字段包含有关子查询的信息。 |
breakdown 对象
breakdown 对象表示有关低级 Lucene 执行的时间统计信息,按方法细分。时间以挂钟纳秒为单位列出,不进行标准化。breakdown 时间包含所有子项时间。breakdown 对象包含以下字段。所有字段都包含整数值。
| 字段 | 描述 |
|---|---|
create_weight | Lucene 中的 Query 对象是不可变的。然而,Lucene 应该能够在多个 IndexSearcher 对象中重用 Query 对象。因此,Query 对象需要保持与执行查询的索引相关联的临时状态和统计信息。为了实现重用,每个 Query 对象生成一个 Weight 对象,该对象保持与 <IndexSearcher, Query> 元组相关联的临时上下文(状态)。create_weight 字段包含创建 Weight 对象所花费的时间。 |
build_scorer | Scorer 迭代匹配的文档并为每个文档生成分数。build_scorer 字段包含生成 Scorer 对象所花费的时间。这不包括对文档评分所花费的时间。Scorer 初始化时间取决于特定查询的优化和复杂性。build_scorer 参数还包括与缓存相关的时间(如果缓存适用且已为查询启用)。 |
next_doc | next_doc Lucene 方法返回与查询匹配的下一个文档的文档 ID。此方法是 advance 方法的特殊类型,等效于 advance(docId() + 1)。next_doc 方法对于许多 Lucene 查询来说更方便。next_doc 字段包含确定下一个匹配文档所需的时间,该时间因查询类型而异。 |
advance | advance 方法是 Lucene 中 next_doc 方法的较低级版本。它也查找下一个匹配的文档,但需要调用查询执行附加任务,例如识别跳过。某些查询(例如布尔查询中的合取(must 子句))无法使用 next_doc。对于这些查询,会计时 advance。 |
match | 对于某些查询,文档匹配分两步执行。首先,文档被近似匹配。其次,通过更全面的过程检查近似匹配的文档。例如,短语查询首先检查文档是否包含短语中的所有术语。接下来,它验证术语是否按顺序排列(这是一个更昂贵的过程)。match 字段仅对使用两步验证过程的查询非零。 |
score | 包含 Scorer 对特定文档评分所花费的时间。 |
shallow_advance | 包含执行 advanceShallow Lucene 方法所需的时间。 |
compute_max_score | 包含执行 getMaxScore Lucene 方法所需的时间。 |
set_min_competitive_score | 包含执行 setMinCompetitiveScore Lucene 方法所需的时间。 |
<method>_count | 包含 <method> 的调用次数。例如,advance_count 包含 advance 方法的调用次数。同一方法的不同调用发生是因为在不同文档上调用了该方法。你可以通过比较不同查询组件中的计数来确定查询的选择性。 |
max_<method> | 任何切片运行查询方法所花费的最大时间。create_weight 方法的分解统计不包括分析的 max 时间,因为该方法在查询级别而不是切片级别运行。仅在启用并发段搜索时包含此字段。 |
min_<method> | 任何切片运行查询方法所花费的最小时间。create_weight 方法的分解统计不包括分析的 min 时间,因为该方法在查询级别而不是切片级别运行。仅在启用并发段搜索时包含此字段。 |
avg_<method> | 任何切片运行查询方法所花费的平均时间。create_weight 方法的分解统计不包括分析的 avg 时间,因为该方法在查询级别而不是切片级别运行。仅在启用并发段搜索时包含此字段。 |
max_<method>_count | 任何切片上 <method> 的最大调用次数。create_weight 方法的分解统计不包括分析的 max 计数,因为该方法在查询级别而不是切片级别运行。仅在启用并发段搜索时包含此字段。 |
min_<method>_count | 任何切片上 <method> 的最小调用次数。create_weight 方法的分解统计不包括分析的 min 计数,因为该方法在查询级别而不是切片级别运行。仅在启用并发段搜索时包含此字段。 |
avg_<method>_count | 任何切片上 <method> 的平均调用次数。create_weight 方法的分解统计不包括分析的 avg 计数,因为该方法在查询级别而不是切片级别运行。仅在启用并发段搜索时包含此字段。 |
collector 数组
collector 数组包含有关 Lucene 收集器的信息。收集器负责协调文档遍历和评分,并收集匹配的文档。使用收集器,单个查询可以记录聚合结果并执行全局查询或后查询过滤器。
| 字段 | 描述 |
|---|---|
name | 收集器名称。在示例响应中,collector 是单个 SimpleTopScoreDocCollector---默认的评分和排序收集器。 |
reason | 包含收集器的描述。有关可能的字段值,请参阅收集器原因。 |
time_in_nanos | 此收集器的总耗时,以纳秒为单位。对于并发段搜索,time_in_nanos 是所有切片的总时间(最后完成的切片执行结束时间与第一个切片执行开始时间之差)。 |
children | 如果收集器具有子收集器(children),此字段包含有关子收集器的信息。 |
max_slice_time_in_nanos | 任何切片所花费的最大时间,以纳秒为单位。仅在启用并发段搜索时包含此字段。 |
min_slice_time_in_nanos | 任何切片所花费的最小时间,以纳秒为单位。仅在启用并发段搜索时包含此字段。 |
avg_slice_time_in_nanos | 任何切片所花费的平均时间,以纳秒为单位。仅在启用并发段搜索时包含此字段。 |
slice_count | 此查询的总切片数。仅在启用并发段搜索时包含此字段。 |
reduce_time_in_nanos | 减少所有切片收集器结果所花费的时间,以纳秒为单位。仅在启用并发段搜索时包含此字段。 |
NOTE
收集器时间是独立计算、组合和标准化的,因此它们与查询时间无关。
收集器原因
下表描述了所有可用的收集器原因。
| 原因 | 描述 |
|---|---|
search_sorted | 对文档进行评分和排序的收集器。存在于大多数简单搜索中。 |
search_count | 计算匹配文档数量但不获取源的收集器。在指定 size: 0 时存在。 |
search_terminate_after_count | 搜索匹配文档并在找到指定数量的文档后终止搜索的收集器。在指定 terminate_after_count 查询参数时存在。 |
search_min_score | 返回分数大于最小分数的匹配文档的收集器。在指定 min_score 参数时存在。 |
search_multi | 其他收集器的包装收集器。当搜索、聚合、全局聚合和后过滤器组合在单个搜索中时存在。 |
search_timeout | 在指定时间段后停止运行的收集器。在指定 timeout 参数时存在。 |
aggregation | 针对指定查询范围运行的聚合收集器。OpenSearch 使用单个 aggregation 收集器为所有聚合收集文档。 |
global_aggregation | 针对全局查询范围运行的收集器。全局范围与指定的查询范围不同,因此为了收集整个数据集,必须运行 match_all 查询。 |
聚合
要分析聚合,请发送聚合请求并将 profile 参数设置为 true。
示例请求:全局聚合
GET /opensearch_dashboards_sample_data_ecommerce/_search
{
"profile": "true",
"size": 0,
"query": {
"match": { "manufacturer": "Elitelligence" }
},
"aggs": {
"all_products": {
"global": {},
"aggs": {
"avg_price": { "avg": { "field": "taxful_total_price" } }
}
},
"elitelligence_products": { "avg": { "field": "taxful_total_price" } }
}
}示例响应:全局聚合
响应包含分析信息:
响应
{
"took": 10,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1370,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"all_products": {
"doc_count": 4675,
"avg_price": {
"value": 75.05542864304813
}
},
"elitelligence_products": {
"value": 68.4430200729927
}
},
"profile": {
"shards": [
{
"id": "[LidyZ1HVS-u93-73Z49dQg][opensearch_dashboards_sample_data_ecommerce][0]",
"inbound_network_time_in_millis": 0,
"outbound_network_time_in_millis": 0,
"searches": [
{
"query": [
{
"type": "ConstantScoreQuery",
"description": "ConstantScore(manufacturer:elitelligence)",
"time_in_nanos": 1367487,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 634321,
"match": 0,
"next_doc_count": 1370,
"score_count": 0,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 173250,
"advance_count": 2,
"score": 0,
"build_scorer_count": 4,
"create_weight": 132458,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 427458
},
"children": [
{
"type": "TermQuery",
"description": "manufacturer:elitelligence",
"time_in_nanos": 1174794,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 470918,
"match": 0,
"next_doc_count": 1370,
"score_count": 0,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 172084,
"advance_count": 2,
"score": 0,
"build_scorer_count": 4,
"create_weight": 114041,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 417751
}
}
]
}
],
"rewrite_time": 42542,
"collector": [
{
"name": "MultiCollector",
"reason": "search_multi",
"time_in_nanos": 778406,
"children": [
{
"name": "EarlyTerminatingCollector",
"reason": "search_count",
"time_in_nanos": 70290
},
{
"name": "ProfilingAggregator: [elitelligence_products]",
"reason": "aggregation",
"time_in_nanos": 502780
}
]
}
]
},
{
"query": [
{
"type": "ConstantScoreQuery",
"description": "ConstantScore(*:*)",
"time_in_nanos": 995345,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 930803,
"match": 0,
"next_doc_count": 4675,
"score_count": 0,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 2209,
"advance_count": 2,
"score": 0,
"build_scorer_count": 4,
"create_weight": 23875,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 38458
},
"children": [
{
"type": "MatchAllDocsQuery",
"description": "*:*",
"time_in_nanos": 431375,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 389875,
"match": 0,
"next_doc_count": 4675,
"score_count": 0,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 1167,
"advance_count": 2,
"score": 0,
"build_scorer_count": 4,
"create_weight": 9458,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 30875
}
}
]
}
],
"rewrite_time": 8792,
"collector": [
{
"name": "ProfilingAggregator: [all_products]",
"reason": "aggregation_global",
"time_in_nanos": 1310536
}
]
}
],
"aggregations": [
{
"type": "AvgAggregator",
"description": "elitelligence_products",
"time_in_nanos": 319918,
"breakdown": {
"reduce": 0,
"post_collection_count": 1,
"build_leaf_collector": 130709,
"build_aggregation": 2709,
"build_aggregation_count": 1,
"build_leaf_collector_count": 2,
"post_collection": 584,
"initialize": 4750,
"initialize_count": 1,
"reduce_count": 0,
"collect": 181166,
"collect_count": 1370
}
},
{
"type": "GlobalAggregator",
"description": "all_products",
"time_in_nanos": 1519340,
"breakdown": {
"reduce": 0,
"post_collection_count": 1,
"build_leaf_collector": 134625,
"build_aggregation": 59291,
"build_aggregation_count": 1,
"build_leaf_collector_count": 2,
"post_collection": 5041,
"initialize": 24500,
"initialize_count": 1,
"reduce_count": 0,
"collect": 1295883,
"collect_count": 4675
},
"children": [
{
"type": "AvgAggregator",
"description": "avg_price",
"time_in_nanos": 775967,
"breakdown": {
"reduce": 0,
"post_collection_count": 1,
"build_leaf_collector": 98999,
"build_aggregation": 33083,
"build_aggregation_count": 1,
"build_leaf_collector_count": 2,
"post_collection": 2209,
"initialize": 1708,
"initialize_count": 1,
"reduce_count": 0,
"collect": 639968,
"collect_count": 4675
}
}
]
}
]
}
]
}
}示例请求:非全局聚合
GET /opensearch_dashboards_sample_data_ecommerce/_search
{
"size": 0,
"aggs": {
"avg_taxful_total_price": {
"avg": {
"field": "taxful_total_price"
}
}
}
}示例响应:非全局聚合
响应包含分析信息:
响应
{
"took": 13,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 4675,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"avg_taxful_total_price": {
"value": 75.05542864304813
}
},
"profile": {
"shards": [
{
"id": "[LidyZ1HVS-u93-73Z49dQg][opensearch_dashboards_sample_data_ecommerce][0]",
"inbound_network_time_in_millis": 0,
"outbound_network_time_in_millis": 0,
"searches": [
{
"query": [
{
"type": "ConstantScoreQuery",
"description": "ConstantScore(*:*)",
"time_in_nanos": 1690820,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 1614112,
"match": 0,
"next_doc_count": 4675,
"score_count": 0,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 2708,
"advance_count": 2,
"score": 0,
"build_scorer_count": 4,
"create_weight": 20250,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 53750
},
"children": [
{
"type": "MatchAllDocsQuery",
"description": "*:*",
"time_in_nanos": 770902,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 721943,
"match": 0,
"next_doc_count": 4675,
"score_count": 0,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 1042,
"advance_count": 2,
"score": 0,
"build_scorer_count": 4,
"create_weight": 5041,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 42876
}
}
]
}
],
"rewrite_time": 22000,
"collector": [
{
"name": "MultiCollector",
"reason": "search_multi",
"time_in_nanos": 3672676,
"children": [
{
"name": "EarlyTerminatingCollector",
"reason": "search_count",
"time_in_nanos": 78626
},
{
"name": "ProfilingAggregator: [avg_taxful_total_price]",
"reason": "aggregation",
"time_in_nanos": 2834566
}
]
}
]
}
],
"aggregations": [
{
"type": "AvgAggregator",
"description": "avg_taxful_total_price",
"time_in_nanos": 1973702,
"breakdown": {
"reduce": 0,
"post_collection_count": 1,
"build_leaf_collector": 199292,
"build_aggregation": 13584,
"build_aggregation_count": 1,
"build_leaf_collector_count": 2,
"post_collection": 6125,
"initialize": 6916,
"initialize_count": 1,
"reduce_count": 0,
"collect": 1747785,
"collect_count": 4675
}
}
]
}
]
}
}响应字段
aggregations 数组包含具有以下字段的聚合对象。
| 字段 | 数据类型 | 描述 |
|---|---|---|
type | String | 聚合器类型。在非全局聚合示例响应中,聚合器类型是 AvgAggregator。全局聚合示例响应包含一个带有 AvgAggregator 子项的 GlobalAggregator。 |
description | String | 包含聚合的 Lucene 解释。有助于区分具有相同类型的聚合。 |
time_in_nanos | Long | 此聚合的总耗时,以纳秒为单位。对于并发段搜索,time_in_nanos 是所有切片的总时间(最后完成的切片执行结束时间与第一个切片执行开始时间之差)。 |
breakdown | Object | 包含有关低级 Lucene 执行的时间统计信息。 |
children | 对象数组 | 如果聚合具有子聚合(children),此字段包含有关子聚合的信息。 |
debug | Object | 某些聚合返回一个 debug 对象,描述底层执行的详细信息。 |
max_slice_time_in_nanos | Long | 任何切片运行聚合所花费的最大时间,以纳秒为单位。仅在启用并发段搜索时包含此字段。 |
min_slice_time_in_nanos | Long | 任何切片运行聚合所花费的最小时间,以纳秒为单位。仅在启用并发段搜索时包含此字段。 |
avg_slice_time_in_nanos | Long | 任何切片运行聚合所花费的平均时间,以纳秒为单位。仅在启用并发段搜索时包含此字段。 |
breakdown 对象
breakdown 对象表示有关低级 Lucene 执行的时间统计信息,按方法细分。breakdown 对象中的每个字段表示在聚合内执行的内部 Lucene 方法。时间以挂钟纳秒为单位列出,不进行标准化。breakdown 时间包含所有子项时间。breakdown 对象包含以下字段。所有字段都包含整数值。
| 字段 | 描述 |
|---|---|
initialize | 包含在 AggregationCollectorManager 创建期间执行 preCollection() 回调方法所花费的时间。对于并发段搜索,initialize 方法包含所有切片的总耗时(最后完成的切片执行结束时间与第一个切片执行开始时间之差)。 |
build_leaf_collector | 包含运行聚合的 getLeafCollector() 方法所花费的时间,该方法创建一个新的收集器来收集给定的上下文。对于并发段搜索,build_leaf_collector 方法包含所有切片的总耗时(最后完成的切片执行结束时间与第一个切片执行开始时间之差)。 |
collect | 包含将文档收集到桶中所花费的时间。对于并发段搜索,collect 方法包含所有切片的总耗时(最后完成的切片执行结束时间与第一个切片执行开始时间之差)。 |
post_collection | 包含运行聚合的 postCollection() 回调方法所花费的时间。对于并发段搜索,post_collection 方法包含所有切片的总耗时(最后完成的切片执行结束时间与第一个切片执行开始时间之差)。 |
build_aggregation | 包含运行聚合的 buildAggregations() 方法所花费的时间,该方法构建此聚合的结果。对于并发段搜索,build_aggregation 方法包含所有切片的总耗时(最后完成的切片执行结束时间与第一个切片执行开始时间之差)。 |
reduce | 包含在 reduce 阶段花费的时间。对于并发段搜索,reduce 方法包含所有切片的总耗时(最后完成的切片执行结束时间与第一个切片执行开始时间之差)。 |
<method>_count | 包含 <method> 的调用次数。例如,build_leaf_collector_count 包含 build_leaf_collector 方法的调用次数。 |
max_<method> | 任何切片运行聚合方法所花费的最大时间。仅在启用并发段搜索时包含此字段。 |
min_<method> | 任何切片运行聚合方法所花费的最小时间。仅在启用并发段搜索时包含此字段。 |
avg_<method> | 任何切片运行聚合方法所花费的平均时间。仅在启用并发段搜索时包含此字段。 |
<method>_count | 所有切片的总方法计数。例如,对于 collect 方法,它是跨所有切片将文档收集到桶中所需的此方法调用总数。 |
max_<method>_count | 任何切片上 <method> 的最大调用次数。仅在启用并发段搜索时包含此字段。 |
min_<method>_count | 任何切片上 <method> 的最小调用次数。仅在启用并发段搜索时包含此字段。 |
avg_<method>_count | 任何切片上 <method> 的平均调用次数。仅在启用并发段搜索时包含此字段。 |