Elasticsearch 2.1 : Result window is too large (index. 最大结果窗口)

标签 elasticsearch

我们从 Elasticsearch 2.1 检索信息并允许用户翻阅结果。当用户请求高页码时,我们收到以下错误消息:

Result window is too large, from + size must be less than or equal to: [10000] but was [10020]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level parameter

elastic docu 说这是因为高内存消耗和使用滚动 api:

Values higher than can consume significant chunks of heap memory per search and per shard executing the search. It’s safest to leave this value as it is an use the scroll api for any deep scrolling https://www.elastic.co/guide/en/elasticsearch/reference/2.x/breaking_21_search_changes.html#_from_size_limits

问题是我不想检索大型数据集。我只想从结果集中非常靠前的数据集中检索一个切片。滚动文档还说:

Scrolling is not intended for real time user requests https://www.elastic.co/guide/en/elasticsearch/reference/2.2/search-request-scroll.html

这给我留下了一些问题:

1) 如果我使用滚动 api 向上滚动到结果 10020(并忽略低于 10000 的所有内容)而不是对结果 10000 执行“正常”搜索请求,内存消耗真的会更低吗(如果是,为什么) 10020?

2) 滚动 API 似乎不是我的一个选项,但我必须增加“index.max_result_window”。有没有人有这方面的经验?

3) 是否还有其他方法可以解决我的问题?

最佳答案

如果您需要深度分页,一种可能的解决方案是增加值 max_result_window。您可以使用 curl 从 shell 命令行执行此操作:

curl -XPUT "http://localhost:9200/my_index/_settings" -H 'Content-Type: application/json' -d '{ "index" : { "max_result_window" : 500000 } }'

对于大约 100k 的值,我没有注意到内存使用量增加。

关于 Elasticsearch 2.1 : Result window is too large (index. 最大结果窗口),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35206409/

相关文章:

java - 如何使用IngestPlugin在Elasticsearch中基于IngestDocument填充indexableField

elasticsearch - Elasticsearch 中的简单分组

elasticsearch - Logstash Elastic Cloud 401未经授权的错误

elasticsearch - ElasticSearch multi_match查询字符串数组

elasticsearch - 带有空格的Elasticsearch字词查询不起作用

elasticsearch - spark 在 elasticsearch 中写入时间戳

elasticsearch 为什么 facet 这么慢?

spring-boot - 千分尺过滤器被CompositeMeterRegistry忽略

elasticsearch - 对动态字段禁用分析器

elasticsearch - Elasticsearch ,搜索不区分大小写的连字符