试试搜索一下吧

如何在ES中找到某字段首次出现的值?

Elasticsearch | 作者 liyh122 | 发布于2018年06月19日 | 阅读数:1634

ES中存在HTTP访问日志,至少包含url和time(访问时间)两个字段,数据量很大。
如何找到指定时间区间内(start~end),首次出现的URL?
已邀请:

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

{
"query": {
"range" : {
"time" : {
"gte" : start_time,
"lte" : end_time,
}
}
},
"size":0,
"aggs": {
"top_time_hits": {
"top_hits": {
"sort": [
{
"time": {
"order": "asc"
}
}
],
"_source": {
"includes": [ "time", "url" ]
},
"size" : 1
}
}
}
}
}
}

要回复问题请先登录注册