Search code examples
elasticsearch

I'm using ElasticSearch 8.7.0, but I can't resolve the update error


I received a failure response when updating in ElasticSearch 8.7.0, but I don't know the solution.

It was created with the following sentence.

curl -XPOST http://localhost:9200/classes/_doc/1 -H "Content-Type: application/json" -d '{"title":"Algrithm", "professor":"John"}'

When I searched, I got good results.

curl -XGET http://localhost:9200/classes/_doc/1?pretty

{ "_index" : "classes", "_id" : "1", "_version" : 7, "_seq_no" : 7, "_primary_term" : 2, "found" : true, "_source" : { "title" : "Algrithm", "professor" : "John" } }

I wanted to add credits here, so I updated it, but I received a failure response.

curl -XPOST http://localhost:9200/classes/_doc/1/_update?pretty -H'Content-Type: application/json' -d '{"doc":{"unit":1}}'

{ "error" : "no handler found for uri [/classes/_doc/1/_update?pretty] and method [POST]" }

Experts, please help... I want to solve this and sleep~~~

Experts, please help... I want to solve this and sleep~~~


Solution

  • You need to run your update like this:

                                           _update goes here
                                                 |
                                                 v
    curl -XPOST http://localhost:9200/classes/_update/1?pretty -H'Content-Type: application/json' -d '{"doc":{"unit":1}}'