elasticsearch - elasticsearch _search api stats 标签有什么作用?
问题描述
我正在尝试在用户使用 _search API 时收集数据,我偶然发现了一个可以放入搜索查询的标签,这可能会为我简化一切,但我找不到足够的信息。
_search 正文中的 stats 标签是否会影响任何内容?喜欢返回的结果?
我能在上面找到的唯一信息是这个页面https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html它所声明的只是字符串,字符串 [ ], Boolean — 用于记录和统计目的的请求的特定标记。elasticsearch 是否真的在某处记录它?
我的 _search 请求示例:
木花
GET myindex/doc/_search
{
"query": {
"match_all": {}
},
"stats": ["my string of data"]
}
卷曲
curl -XGET "http://localhost:9200/myindex/doc/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"match_all": {}
},
"stats": ["my string of data"]
}'
解决方案
查询中的stats
关键字_search
旨在定义一些统计信息组,您可以稍后使用_stats
API 进行查询。例如,假设您myindex
使用my-query
组进行查询:
curl -XGET "http://localhost:9200/myindex/doc/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"match_all": {}
},
"stats": ["my-query"]
}'
然后,您可以使用以下查询获取该组的索引级搜索统计信息:
curl -XGET "http://localhost:9200/myindex/_stats/search?groups=my-stats"
你会得到这样的东西:
{
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_all": {
"primaries": {
"search": {
"open_contexts": 0,
"query_total": 5806,
"query_time_in_millis": 73948,
...
"groups": {
"my-query": { <----------
"query_total": 8,
"query_time_in_millis": 81,
...
}
}
}
},
"total": {
"search": {
"open_contexts": 0,
"query_total": 5806,
"query_time_in_millis": 73948,
...
"groups": {
"my-query": { <----------
"query_total": 8,
"query_time_in_millis": 81,
...
}
}
}
}
},
"indices": {
"listings-master": {
"uuid": "oUYHBiU8RVayI95uCw3Clg",
"primaries": {
"search": {
"open_contexts": 0,
"query_total": 5806,
"query_time_in_millis": 73948,
...
"groups": {
"my-query": { <----------
"query_total": 8,
"query_time_in_millis": 81,
...
}
}
}
},
"total": {
"search": {
"open_contexts": 0,
"query_total": 5806,
"query_time_in_millis": 73948,
...
"groups": {
"my-query": { <----------
"query_total": 8,
"query_time_in_millis": 81,
...
}
}
}
}
}
}
}
推荐阅读
- d3.js - D3 日历热图。如何在热图的矩形中显示数字或任何内容
- sql - SQL计算两次之间的时间差并显示小时
- python - plotly dash中的外部css
- php - 如何获取当前帖子的作者 ID(WordPress)
- javascript - getSourceData(), afterchange Handsontable js vue
- react-native - 如何在用户滑动时从 PanGestureHandler 滑动移动获取当前 Y 值
- xml - 使用 Biopython 为 SARS 病毒在 Python 中运行 BLAST。我的输出根本没有出现!有人检查我的代码吗?
- python - 为什么在 zip() 上调用 list() 会清空内容?如何在不更改内容的情况下打印 zip 对象?
- google-apps-script - Google Apps 脚本:使用各种脚本(依赖项)时未定义的变量或函数
- c++ - 结构原型中的继承