从Elasticsearch索引中检索最小时间戳的最快方法是什么? [英] What's the fastest manner to retrieve min timestamp from Elasticsearch indices?
本文介绍了从Elasticsearch索引中检索最小时间戳的最快方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我认为有两种实现方法。
但是我不知道哪个更快,因为我没有太多数据要测试。
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.
像下面的SQL:
SELECT min(occur_time) FROM event_*
SELECT occur_time FROM event_* order by occur_time limit 1
推荐答案
您可以运行大小为1的查询,按@timestamp递增,甚至包括include_fields: @timestamp以便仅获取最小时间戳字段:
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" ]
}
}
这篇关于从Elasticsearch索引中检索最小时间戳的最快方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文