Komal Kartan
Komal Kartan

Reputation: 35

Elasticsearch POST and PUT

I am new to elasticsearch and I am trying to learn the APIs.

So usually you use POST to create something new and PUT to update the existing one. But I have noticed that, when I use POST to create new index, I get error saying, use PUT.

And which one do we use for creating new documents PUT or POST. In my case PUT worked, but not POST. I was looking if I can get a simple explanation to clarify this. I am using Kibana

Upvotes: 0

Views: 677

Answers (1)

Val
Val

Reputation: 217314

The rule of thumb is

  • Use PUT to create a new document with a specific ID that you provide yourself
  • Use POST to create a new document and let Elasticsearch generate a document ID automatically

Upvotes: 2

Related Questions