Elasticsearch -from + size设置

Elasticsearch 查询索引结果时,用于分页的两个属性 from和size。用于查询时,默认from=0、size=0。而在生产环境时,查询的数据要大很多。有时是几百G,甚至P级。

在设置size时,超过10000。会出现报错。

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

说是size 不能超过10000! 查阅资料,显示可以通过设置,改变:

PUT _settings
{
    "index": {
        "max_result_window": "10000000"
    }
}

经过测试,还是不可以。原因是我的Elasticsearch是集群环境(部署了三个master两个data节点)。上面的方式只能改变单节点的size。

我想要不就通过yaml文件,不是环境变量。重新部署吧。大胆猜想,然后实践。因为是kubernetes部署的elasticsearch集群。所以直接改他们的yaml文件,重新部署就行啦。

加上配置:

         - name: "index.max_result_window"
           value: "10000000"

然后部署:

  kubectl apply -f  es.yaml

但是查看状态的时候,出错。查看日志:

*******************************************************************************
Found index level settings on node level configuration.

Since elasticsearch 5.x index level settings can NOT be set on the nodes 
configuration like the elasticsearch.yaml, in system properties or command line 
arguments.In order to upgrade all indices the settings must be updated via the 
/${index}/_settings API. Unless all settings are dynamic all indices must be closed 
in order to apply the upgradeIndices created in the future should use index templates 
to set default values. 

Please ensure all required values are updated on all indices by executing: 

curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
  "index.max_result_window" : "100000"
}'
*******************************************************************************

[2018-11-23T07:03:13,840][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [elasticsearch-master-0] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: node settings must not contain any index level settings
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.4.jar:5.6.4]

可以看到es 5.X以后,就不可以在yaml文件,系统属性,以及命令行参数设置索引级别的配置啦。

因此只能通过他给的提示:

curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
  "index.max_result_window" : "100000"
}'

设置size长度。

你可能感兴趣的:(Elasticsearch)