# New Java client how to estimate size of BulkRequest

**URL:** <https://discuss.elastic.co/t/new-java-client-how-to-estimate-size-of-bulkrequest/316211>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [October 10, 2022, 11:32am UTC](https://discuss.elastic.co/t/new-java-client-how-to-estimate-size-of-bulkrequest/316211 "2022-10-10T11:32:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabian-froehlich](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fabian-froehlich/32/104886_2.png) [@fabian-froehlich](https://discuss.elastic.co/u/fabian-froehlich)\
**Post date:** [October 10, 2022, 11:32am UTC](https://discuss.elastic.co/t/new-java-client-how-to-estimate-size-of-bulkrequest/316211/1 "2022-10-10T11:32:00Z")

</div>

Is there a efferent way to estimate the size of the bulk request in the new `ElasticsearchClient` ?

Currently our in the `HighLevelRest`-Client we use the method `bulkRequest.estimatedSizeInBytes()` to check whether another request would fit. If that is the case, we add another Request. If not, we send the former created `BulkRequest` to our Elasticsearch-Cluster. And start adding new Requests into a new `BulkRequest` instance.

But while migrating to the new `ElasticsearchClient` I did not find anything similar to that.

Since the Builders do only allow to be build once it might be wise to estimate the size of an `BulkOperation` instead and add them up before adding to the builder. But I did not find a solution for that either.

---

<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:** [November 7, 2022, 11:32am UTC](https://discuss.elastic.co/t/new-java-client-how-to-estimate-size-of-bulkrequest/316211/2 "2022-11-07T11:32:59Z")

</div>

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