Elasticsearch 消除重复结果
给定以下文档:
name: Peter, enterTime: 2022-01-27
name: Peter, enterTime: 2022-01-28
name: Peter, enterTime: 2022-01-29
name: Jenny, enterTime: 2022-01-29
name: Jenny, enterTime: 2022-01-30
name: Peter, enterTime: 2022-01-31
name: Peter, enterTime: 2022-02-01
name: Jenny, enterTime: 2022-02-02
name: Jenny, enterTime: 2022-02-03
我想编写一个elasticsearch查询,如果下一个结果相同,则按名称对结果进行分组,并且仅显示第一个结果。 我期待的结果:
name: Peter, enterTime: 2022-01-27
name: Jenny, enterTime: 2022-01-29
name: Peter, enterTime: 2022-01-31
name: Jenny, enterTime: 2022-02-02
我尝试过聚合查询和折叠,但到目前为止我失败了。任何提示将不胜感激。
Given the following documents:
name: Peter, enterTime: 2022-01-27
name: Peter, enterTime: 2022-01-28
name: Peter, enterTime: 2022-01-29
name: Jenny, enterTime: 2022-01-29
name: Jenny, enterTime: 2022-01-30
name: Peter, enterTime: 2022-01-31
name: Peter, enterTime: 2022-02-01
name: Jenny, enterTime: 2022-02-02
name: Jenny, enterTime: 2022-02-03
I want to write a elasticsearch query to group the result by name if the next result is the same, and only display the first result.
Result that I am expecting:
name: Peter, enterTime: 2022-01-27
name: Jenny, enterTime: 2022-01-29
name: Peter, enterTime: 2022-01-31
name: Jenny, enterTime: 2022-02-02
I have tried aggregation query and collapse but I failed miserably so far. Any tips would be very appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论