-2

I'm new to Elastic search and I'm doing a task in which I need to upload more number of documents to ES. Whenever I upload everytime, I need to specify document id for that document in IndexRequest api. Is there any way in java so that i can insert documents without giving id for it (i.e creating random document id's for my documents).

1 Answers1

1

Please have a look at https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.13/java-rest-high-document-index.html

In order to have the id autogenerated, just ommit this call:

request.id("1");

This should do the trick for single document operations.

If you need bulk changes, see https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-document-bulk.html

In this case, also remove the .id("1") method call.

ibexit
  • 3,465
  • 1
  • 11
  • 25