What's the fastest manner to retrieve min timestamp from Elasticsearch indices?

余生长醉 提交于 2019-12-25 03:42:16

问题


In my opinion, there are two ways to implement it. But I don't know which is faster, because I don't have much data to test.

Like SQL below:

SELECT min(occur_time) FROM event_*
SELECT occur_time FROM event_* order by occur_time limit 1

回答1:


You can run a query, with size:1, sorted by @timestamp ascending, and even include_fields:@timestamp in order to fetch back only the minimum timestamp field:

{
   "size":1,
   "sort": [{"@timestamp":"asc"}],
   "_source": {
         "includes": [ "@timestamp" ]
   }
 }


来源:https://stackoverflow.com/questions/54016019/whats-the-fastest-manner-to-retrieve-min-timestamp-from-elasticsearch-indices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!