How to index list of data in Elasticsearch using java api (need to be index quickly)

Hi Team,
can anyone advice me how to proceed this ?

i am having list of data , need to index the data in particular index (index name : customers) , which logic need to use using java api? i am using like this . indexing time is taking too much
listofdata - customers
for(Customers customer : customers) {

bulkRequest.addAction(((Index.Builder) ((Index.Builder) ((Index.Builder) new Index.Builder(customer).index("test_prod"))
.type("test")).id(customer.getId())).build());
}

With a similar strategy I'm able to index locally on my laptop around 12k-15k docs per second.

How slow it is on your end? Which part is slow?

BTW, you should use the BulkProcessor class instead of sending the whole customers dataset at once. It's better to send smaller requests.

See https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-bulk.html#java-rest-high-document-bulk-processor

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.