I have just started learning Elasticsearch. While going through the online documentation which talks about use of REST APIs, I have observed that whenever a create / modify / delete action is required, sometimes POST is used as a verb and rest of the times PUT is used in REST API syntax.
Is there a logical criteria to decide when to use PUT versus POST in REST APIs ?
And our understanding of the semantics at the time when we made the APIs. And backwards compatibility constraints. And whatever "feels" natural to the person who implemented the API.
Where it makes a lot of sense Elasticsearch maps the HTTP verbs to useful things. But when it doesn't make a ton of sense we just go with whatever verb feels good rather than trying to be super strict about REST. Also, we don't do linked data, instead relying on you to build links from context. I'm told that is particularly non-REST. But it is what we do.
While the majority of the confusion is clear, however from the documentation, I found at least one instance where "POST" was used even in case where explicit "_id" field was specified. The example was taken from "Batch Processing" instance. The documentation, along with the example, was taken from https://www.elastic.co/guide/en/elasticsearch/reference/current/_batch_processing.html .
Please help and suggest if I should taken the above case as a specific exception and generally go with the understanding you have mentioned earlier.
I am still OK with this however just wanted a method / approach to remember where to use "PUT" versus "POST". I haven't tried using "PUT" versus "POST" in command line as I don't have an instance available to practice on however I will surely try it to observe the error message.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.