Is there a real difference between POST and PUT in the ElasticSearch API? When I look at documentation such as this, it looks like they can be substituted for each other.
I ask because I write an application in which, under certain circumstances, user input is supposed to be put in ElasticSearch, and I don't want users indadvertedly changing configuration by submitting specially crafted documents. I thought I could do this by always using PUT (because I assumed POST would be used for configuration changes), but it seems like I misunderstood.
What I am asking for is, how can I see the difference between putting a document into ElasticSearch and changing configuration to ElasticSearch. If it's not a distinction of HTTP method, is it a distinction of URL?
Thanks, this describes the difference between GET and POST quite well, but my question is about PUT vs POST. I do understand that POST can be used as a substitute for GET when it is not possible to use GET with a body, but does the same apply to PUT? Can POST be used as a substitute for PUT? If so, how does ElasticSearch know which method was actually meant to be used if POST is used?
The only difference I'm aware of is that a POST can be used to achieve auto-generation of ids whereas a PUT is used when you want to specify an id. See the following for more details:
The information there makes sense to me, but it leaves a few stones unturned:
/{index}/{type}/{id}
Clear: I can use PUT to add a document because I specified the id. It is my responsibility that the id doesn't clash with an existing document, or it will be overwritten.
Unclear: Would it be correct (allowed) to use POST here?
Unclear: Does EVERYPOST store a document? Or are there certain "special" documents that change configuration?
/{index}/{type}
Clear: I MUST use POST to add a document, because I don't specify an id.
Unclear: Can I safely add documents without fearing overwrite?
Unclear: Does EVERYPOST store a document? Or are there certain "special" documents that change configuration?
/{index}
Unclear: what will a POST operation do here? Or a PUT operation? I found examples that change configuration, but are there other possibilities?
As of my knowledge the http requests have some standards. In that PUT is using to insert a new value and the POST is used for update the existing values. Its not belongs to ES alone. The POST, PUT, DELETE, GET, HEAD etc... belongs to all http requests.
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.