# RestClient and Tranport client api

**URL:** <https://discuss.elastic.co/t/restclient-and-tranport-client-api/89236>\
**Category:** Elasticsearch\
**Created:** [June 13, 2017, 4:15pm UTC](https://discuss.elastic.co/t/restclient-and-tranport-client-api/89236 "2017-06-13T16:15:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshraddha](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jshraddha](https://discuss.elastic.co/u/jshraddha)\
**Post date:** [June 13, 2017, 4:15pm UTC](https://discuss.elastic.co/t/restclient-and-tranport-client-api/89236/1 "2017-06-13T16:15:57Z")

</div>

I used RestCLient and there I was appending following line  
`String actionMetaData = String.format("{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\" } }%n", index, type);`

This way I was creating my json for almost 500+ docs and then creating entity object and ingesting data to elasticsearch through RestClient.performRequest.

This operation was very quick. But now when I use transport client and try bulkprocessing it is taking so much time. Is there any way to do it similar to RestClient where I can give whole list of document in a single request as it is without iterating it.

I am having a json file which contains an array of elements. Array size is around 300/400. What I am doing is I am iterating over this array and taking single element as a one document adding that document to bulkProcessor. So what happens is it iterates over 300 elements adds to bulkProcessor one by one. This takes time. This is a single file containing 300 elements but I will be having so many files like this. So inserting let say 20 file's data takes almost 5mins or something. May be I will be doing it is some wrong way. Previously when I used RestClient I used to append the line which i have mentioned above to each document and just inserting all the element's array so that was a one time request for 300 docs and it was doing it very quickly so inserting data for 20 files was not taking more than a minute. Is there anything similar for transport client or bulkProcessor where I can give whole array of 300 elements at one go?

---

<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:** [July 11, 2017, 4:16pm UTC](https://discuss.elastic.co/t/restclient-and-tranport-client-api/89236/2 "2017-07-11T16:16:02Z")

</div>

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