我正在尝试在用户使用_search API时收集数据,但我偶然发现了一个可以放入搜索查询中的标记,该标记可能会简化我的工作,但我找不到足够的信息。
_search主体中的stats标记是否会影响任何内容;喜欢返回结果吗?
我只能在此页面https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html上找到唯一的信息,它声明的所有内容都是String,String [],Boolean-请求的特定标记,用于记录和统计。 elasticsearch实际上将它记录在某个地方吗?
我的_search请求示例:
基巴纳
GET myindex/doc/_search
{
"query": {
"match_all": {}
},
"stats": ["my string of data"]
}
curl
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"]
}'
然后,您可以使用以下查询获取该组的index-level search statistics:
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,
...
}
}
}
}
}
}
}
关于elasticsearch - elasticsearch _search api stats标签有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52488959/