“error” : “no handler found for uri [/test1/_doc/1/update?pretty=true] and method [POST]或者[GET]”

一、GET报错原因:type被弃用!

PUT /test1/type/1
{
"name":"李华", 
"age":18 
}

报错:

"error" : "no handler found for uri [/test1/type/1?pretty=true] and method [PUT]"

解决办法:将type修改为_doc,默认的数据类型

PUT /test1/_doc/1
{
"name":"李华", 
"age":18 
}

PUT创建新的索引成功

{
  "_index" : "test1",
  "_id" : "1",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

二、POST报错原因:语法更新,原来的语法有可能是错的

POST /test1/_doc/1/_update
{
  "doc":{
    "name":"肖肖"
  }
}

报错:

"error" : "no handler found for uri [/test1/_doc/1/update?pretty=true] and method [POST]

解决办法:

POST /test1/_update/1/
{
  "doc":{
    "name":"肖肖"
  }
}

成功修改更新:

{
  "_index" : "test1",
  "_id" : "1",
  "_version" : 2,
  "result" : "updated",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 4,
  "_primary_term" : 1
}
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐