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

**URL:** <https://discuss.elastic.co/t/how-to-index-list-of-data-in-elasticsearch-using-java-api-need-to-be-index-quickly/149629>\
**Category:** Elasticsearch\
**Created:** [September 24, 2018, 7:39am UTC](https://discuss.elastic.co/t/how-to-index-list-of-data-in-elasticsearch-using-java-api-need-to-be-index-quickly/149629 "2018-09-24T07:39:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnrabi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johnrabi/32/67223_2.png) [@johnrabi](https://discuss.elastic.co/u/johnrabi)\
**Post date:** [September 24, 2018, 7:39am UTC](https://discuss.elastic.co/t/how-to-index-list-of-data-in-elasticsearch-using-java-api-need-to-be-index-quickly/149629/1 "2018-09-24T07:39:41Z")

</div>

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());  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 24, 2018, 8:13am UTC](https://discuss.elastic.co/t/how-to-index-list-of-data-in-elasticsearch-using-java-api-need-to-be-index-quickly/149629/2 "2018-09-24T08:13:18Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-bulk.html#java-rest-high-document-bulk-processor)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 22, 2018, 8:13am UTC](https://discuss.elastic.co/t/how-to-index-list-of-data-in-elasticsearch-using-java-api-need-to-be-index-quickly/149629/3 "2018-10-22T08:13:22Z")

</div>

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