问题
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