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
相关产品推荐
相关产品推荐

