You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Elasticsearch发送PUT/POST请求持续报错,GET请求正常

Elasticsearch PUT/POST请求报错"No handler found for uri"的解决办法
  • 版本兼容性问题
    你使用的是Elasticsearch 2.x版本的示例语法,但7.x及以上版本已移除了文档类型(type)字段,原路径/blog/article/1中的article属于废弃的类型参数。改为新版语法即可:

    curl -XPUT 'http://localhost:9200/blog/_doc/1' -d '{"title": "New version of Elasticsearch released!", "content": "Version 2.2 released today!", "priority": 10, "tags": ["announce", "elasticsearch", "release"] }'
    

    其中_doc是ES 7+规定的默认文档类型标识,也可以用_create强制创建新文档(若ID已存在则报错)。

  • 索引未创建
    先执行curl -XGET 'http://localhost:9200/blog'检查blog索引是否存在。如果返回404,需先创建索引:

    curl -XPUT 'http://localhost:9200/blog'
    

    部分版本支持在写入文档时自动创建索引,可在请求后追加参数?op_type=create尝试。

  • 请求语法解析错误
    确保shell命令中的引号和转义符正确。如果使用双引号包裹URL,需转义请求体中的双引号:

    curl -XPUT "http://localhost:9200/blog/_doc/1" -d "{\"title\": \"New version of Elasticsearch released!\", \"content\": \"Version 2.2 released today!\", \"priority\": 10, \"tags\": [\"announce\", \"elasticsearch\", \"release\"] }"
    
  • 集群状态异常
    执行curl -XGET 'http://localhost:9200/_cluster/health'查看集群健康状态。若状态为red,说明节点存在故障(如磁盘空间不足、节点未正常启动),需先修复集群问题再尝试写入操作。

内容的提问来源于stack exchange,提问作者Qwerty

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 03:20:32