ES单节点部署使用查询数据超10000条时,出现报错,后在查相关资料发现需要设置参数命令如下
curl -H "Content-Type: application/json" -XPUT 127.0.0.1:9200/http_index/_settings?pretty -d '{"index.max_result_window":"20000000"}'

但配置后又出现新的问题,查看es的健康状态发现
status是黄色。
http://127.0.0.1:9200/_cat/health?v

可以看到某些索引对应的分片是UNASSIGNED(未分片)状态。经多方百度,得到解决方案:
修改索引settings的number_of_replicas为0即可。
具体原因可参考:https://www.datadoghq.com/blog/elasticsearch-unassigned-shards/#reason-2-too-many-shards-not-enough-nodes

命令调整过程:
百度出来的命令如下
curl -XPUT http://127.0.0.1:9200/_settings?pretty -d '{ "index": { "number_of_replicas": 0 } }' -H "Content-Type: application/json"
但是执行命令的时候一直报错

com.fasterxml.jackson.core.JsonParseException: Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
 at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@34efbd73; line: 1, column: 2]
    at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702) ~[jackson-core-2.8.11.jar:2.8.11]
…………
经查证,在标准json中,要求键和值都要用双引号("")包括的,所以修改原来的命令为:curl -XPUT http://127.0.0.1:9200/_settings?pretty -d "{ "index": { "number_of_replicas": 0 } }" -H "Content-Type: application/json"
但是这时候又报别的错了

com.fasterxml.jackson.core.JsonParseException: Unexpected character ('c' (code 99)): was expecting double-quote to start field name
at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@169c7101; line: 1, column: 4]
    at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702) ~[jackson-core-2.8.11.jar:2.8.11]
…………
又查了下,然后才查到windows下curl有可能不支持单引号,如果有报错,还请改成双引号,内部使用转义字符转义。
然后就又调整了次命令,这次最终运行成功了。
curl -XPUT http://192.168.1.33:9200/_settings?pretty -d "{ \"index\": { \"number_of_replicas\": 0 } }" -H "Content-Type: application/json"
运行结果截图
然后再查看es健康状态和索引状态,都变成了green
es索引状态截图
另外的坑
一般执行上面的语句就完事儿了。但是执行后会报错:

{"error":{"root_cause":[{"type":"cluster_block_exception","reason":"blocked by:
[FORBIDDEN/12/index read-only / allow delete (api)];"}],"type":"cluster_block_ex
ception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api
)];"},"status":403}
最终解决方法是,先执行如下语句,修改单个索引只读状态,然后再修改该索引的分片副本集。

curl -XPUT 192.168.1.33:9200/address/_settings -d "{\"index.blocks.read_only_allow_delete\": null}" -H "Content-Type: application/json"
#执行成功后,继续执行
curl -XPUT 192.168.1.33:9200/address/_settings -d "{\"number_of_replicas\": 0}" -H "Content-Type: application/json"

后执行配置

 

 一路的问题惊险有刺激,总算配置成功了。。。。。