ES Java Bulk Timeout Error

I'm trying to index docs in bulk for some reason I keep getting a timeout exception. However when I try to index a single document, it works perfectly.

Here's the code for indexing a single document

Reader reader = new StringReader(jsonString);
IndexRequest<JsonData> request = IndexRequest.of(i -> i.index(indexName).withJson(reader));
        esClient.index(request).whenComplete((response, exception) ->
            if (exception != null)
                System.out.println("Exception = " + exception);

Here's the code for BulkRequests

BulkRequest.Builder builder = new BulkRequest.Builder();
builder.timeout(Time.of(time -> time.time("2m")));

JsonpMapper jsonpMapper = logManager.getMapper();
JsonProvider jsonProvider = jsonpMapper.jsonProvider();

for (EsLog log: logs) {
           String logJson;
           try {
                logJson = mapper.writeValueAsString(log);
            } catch (JsonProcessingException e) {
                logJson = "{}";
            Reader reader = new StringReader(logJson);
                    op -> op.index(
                            idx -> idx.index(indexName)
                                    .document(JsonData.from(jsonProvider.createParser(reader), jsonpMapper))

        esClient.bulk(, exception) -> {
            if (exception != null) {
                System.out.println("Exception : " + exception.getMessage());
            } else {
                for (BulkResponseItem res: bulkResponse.items()) {

I had some errors using the POJO, so I followed the solution from here for bulk requests

The code to index a single document works properly but the bulk index code throws a timeout exception.

Welcome to our community! :smiley:

Please don't post pictures of text, logs or code. They are difficult to read, impossible to search and replicate (if it's code), and some people may not be even able to see them :slight_smile: