gpt4 book ai didi

elasticsearch - 分页Elasticsearch汇总结果

转载 作者:行者123 更新时间:2023-12-03 00:42:21 26 4
gpt4 key购买 nike

想象一下,我有两种记录:一个存储桶和一个项目,其中存储在存储桶中,而存储桶中的项目可能相对较少(通常不超过4个,从不超过10个)。这些记录被压缩为一个(具有更多存储桶信息的项目),并放置在Elasticsearch中。
我要解决的任务是通过依赖项属性的过滤查询一次找到500个存储桶(最大),其中包含所有相关项,而我受困于限制/抵消聚合。我该如何执行此类任务?我看到了top_hits聚合,它使我可以控制相关项目数量的大小,但是我找不到线索如何控制返回的存储桶的大小。

更新:好的,我非常愚蠢。 size聚合的terms参数为我提供了限制。有什么方法可以执行胶印任务吗?我不需要100%的精度,并且可能永远不会分页显示这些结果,但是无论如何我都希望看到此功能。

最佳答案

我认为我们不会很快看到此功能,请参阅GitHub上的相关讨论。

Paging is tricky to implement because document counts for terms aggregations are not exact when shard_size is less than the field cardinality and sorting on count desc. So weird things may happen like the first term of the 2nd page having a higher count than the last element of the first page, etc.



提到了一种有趣的方法,您可以在第一页上请求类似前20个结果,然后在第二页上运行相同的聚合,但排除您在上一页中已经看到的那20个术语,依此类推。但这不允许您“随机”访问任意页面,必须按顺序浏览页面。

...if you only have a limited number of unique values compared to the number of matched documents, doing the paging on client-side would be more efficient. On the other hand, on high-cardinality-fields, your first approach based on an exclude would probably be better.

关于elasticsearch - 分页Elasticsearch汇总结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33019482/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com