Elasticsearch 消除重复结果

发布于 2025-01-11 04:21:02 字数 631 浏览 1 评论 0原文

给定以下文档:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文