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"
后执行配置

一路的问题惊险有刺激,总算配置成功了。。。。。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类