[英]How can we get the minimum and maximum dates of data in each indices in elastic search?
How can we get the minimum and maximum dates of data in each indices in elastic search? elasticsearch中如何获取每个索引中数据的最小和最大日期?
I was going through the documentation but not able to understand which API will help get the min and max dates of data in each indices in elastic search.我正在浏览文档,但无法理解哪个 API 将有助于获取弹性搜索中每个索引中数据的最小和最大日期。
I believe you could address that using the aggregation
feature of Elasticsearch. You could use the Min and Max metric aggregation.我相信您可以使用 Elasticsearch 的
aggregation
功能来解决这个问题。您可以使用Min和Max指标聚合。
This would look like that using the api:这看起来像使用 api:
GET <The Index>/_search
{
"size": 0,
"query": {
"match_all": {}
},
"aggs": {
"min": {
"min": {
"field": "<The date>"
}
},
"max":{
"max": {
"field": "<The date>"
}
}
}
}
The result should look like so:结果应如下所示:
{
"took": 0,
"timed_out": false,
"_shards": {
...
},
"hits": {
"total": {
"value": 10000,
"relation": "gte"
},
"max_score": null,
"hits": []
},
"aggregations": {
"min": {
"value": 1660521603764,
"value_as_string": "2022-08-15T00:00:03.764Z"
},
"max": {
"value": 1665431791459,
"value_as_string": "2022-10-10T19:56:31.459Z"
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.