gpt4 book ai didi

java - 是否可以将 Integer.MAX_VALUE 传递给elasticsearch而不影响性能?

转载 作者:行者123 更新时间:2023-12-02 10:08:16 25 4
gpt4 key购买 nike

我正在尝试使用Java API来查询elasticsearch以获取所有不同的字段。

TermsAggregationBuilder aggregation =
AggregationBuilders.terms("count").field(field).
size(Integer.MAX_VALUE).
order(BucketOrder.key(true));

我事先不知道字段的基数。可以在不影响 Elasticsearch 性能的情况下传递 Integer.MAX_VALUE 吗?或者有什么替代方案吗?

最佳答案

引用弹性documentation :

If you want to retrieve all terms or all combinations of terms in a nested terms aggregation you should use the Composite aggregation which allows to paginate over all possible terms rather than setting a size greater than the cardinality of the field in the terms aggregation. The terms aggregation is meant to return the top terms and does not allow pagination

还有:

The higher the requested size is, the more accurate the results will be, but also, the more expensive it will be to compute the final results (both due to bigger priority queues that are managed on a shard level and due to bigger data transfers between the nodes and the client).

所以答案是:使用 MAX_VALUE 可能不是一个好主意,不仅因为潜在的性能影响,更因为:这样做在概念上是错误的。

关于java - 是否可以将 Integer.MAX_VALUE 传递给elasticsearch而不影响性能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55178516/

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