ES备忘录
学习ES途中,记录相关问题,获取成长积累
ES官方文档
命令相关
设置相关
- 最大返回数量问题
ES 默认返回10000 条数据,超过10000条,要么使用scroll 进行查询,要么设置最大返回值,否则报如下错误
“reason”: “Result window is too large, from + size must be less than or equal to: [10000] but was [10001]. 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 setting.”
设置最大数量可以按照如下方法进行调试
/indexName/_settings
{“max_result_window”:“1000000000”}
- 最大聚合问题
ES针对聚合做了性能优化,默认不允许聚合数据过大,如果聚合体返回数据过大,返回如下错误
{“error”:{“root_cause”:[{“type”:“too_many_buckets_exception”,“reason”:“Trying to create too many buckets. Must be less than or equal to: [10000] but was [10001]. This limit can be set by changing the [search.max_buckets] cluster level setting.”,“max_buckets”:10000}],“type”:“search_phase_execution_exception”,“reason”:“all shards failed”,“phase”:“query”,“grouped”:true,“failed_shards”:[{“shard”:0,“index”:“recommend”,“node”:“FJazr4BeSqGp5x8hS0UDxw”,“reason”:{“type”:“too_many_buckets_exception”,“reason”:“Trying to create too many buckets. Must be less than or equal to: [10000] but was [10001]. This limit can be set by changing the [search.max_buckets] cluster level setting.”,“max_buckets”:10000}}]},“status”:503}
此时可以通过错误中的提示,进行对应的参数设置
/_cluster/settings
{“persistent”: {“search.max_buckets”: 100000000}}