Reputation: 4670
I am new to ElasticSearch (ES). Day one on the java high level API.
I understand that POST a document allows ES to auto-generate the document ID. PUT allows me to use a pre-existing ID.
From the API docs here, I am not sure how to differentiate between the two approaches when indexing a new document. I wish to use the POST approach.
Upvotes: 0
Views: 671
Reputation: 288
The Java API has an overloaded IndexRequest constructor. If you don't want to specify the ID, you don't have to.
public IndexRequest(String index, String type) {
...
}
public IndexRequest(String index, String type, String id) {
...
}
Presumably the former is a POST request and the latter is a PUT.
Upvotes: 1