quarkusio/quarkus · error · RuntimeException
The indexing operation encountered errors.
Error message
The indexing operation encountered errors.
What it means
Thrown by FruitService.index after executing an Elasticsearch bulk request: the co-eloquent Java client's BulkResponse.errors() flag is true, meaning at least one individual bulk item failed to index. The service deliberately throws a generic RuntimeException instead of surfacing per-item details.
Source
Thrown at integration-tests/elasticsearch-java-client/src/main/java/io/quarkus/it/elasticsearch/java/FruitService.java:88
}
SearchResponse<Fruit> searchResponse = client.search(searchRequest, Fruit.class);
HitsMetadata<Fruit> hits = searchResponse.hits();
return hits.hits().stream().map(Hit::source).collect(Collectors.toList());
}
public void index(List<Fruit> list) throws IOException {
BulkRequest.Builder br = new BulkRequest.Builder();
for (var fruit : list) {
br.operations(op -> op
.index(idx -> idx.index("fruits").id(fruit.id).document(fruit)));
}
BulkResponse result = client.bulk(br.build());
if (result.errors()) {
throw new RuntimeException("The indexing operation encountered errors.");
}
}
public void delete(List<String> list) throws IOException {
BulkRequest.Builder br = new BulkRequest.Builder();
for (var id : list) {
br.operations(op -> op.delete(idx -> idx.index("fruits").id(id)));
}
BulkResponse result = client.bulk(br.build());
if (result.errors()) {
throw new RuntimeException("The indexing operation encountered errors.");
}
}
}View on GitHub (pinned to e1c734241f)
Solutions
- Inspect result.items() per-item failure reasons and log/fix the failing document before retrying.
- Verify the 'fruits' index mapping matches the Fruit document fields (delete/recreate the index if stale).
- Ensure the Elasticsearch container/Dev Service is healthy and reachable on the configured host/port.
- Align the elasticsearch-java client version with the server version.
Example fix
// before
if (result.errors()) { throw new RuntimeException("The indexing operation encountered errors."); }
// after
if (result.errors()) {
result.items().stream().filter(i -> i.error() != null)
.forEach(i -> Log.error("Bulk item failed: " + i.id() + " -> " + i.error().reason()));
throw new RuntimeException("The indexing operation encountered errors.");
} Defensive patterns
Strategy: try-catch
Validate before calling
// ensure cluster is healthy before bulk
com.fasterxml.jackson.databind.JsonNode health = restClient.performRequest(new Request("GET", "/_cluster/health"));
// require status != red and index exists Type guard
null
Try / catch
try {
fruitService.index(fruits);
} catch (RuntimeException e) {
if (e.getMessage().contains("The indexing operation encountered errors")) {
log.error("Bulk indexing partially failed; inspect per-item errors and retry failed ids");
} else throw e;
} Prevention
- Wait for Elasticsearch readiness (cluster health green/yellow) before bulk operations.
- Recreate the 'fruits' index when the Fruit schema changes.
- Keep elasticsearch-java client version aligned with the server.
- Log per-item bulk errors instead of only the aggregate flag.
When it happens
Trigger: client.bulk(...) where any document (e.g. a fruit with duplicate id conflicting mapping or invalid document) fails; index 'fruits' having a mapping that rejects a field value; shard unavailability on the Elasticsearch node.
Common situations: Elasticsearch Dev Service not fully ready / wrong port; mapping conflicts after schema changes; version mismatch between elasticsearch-java client and server; cluster health red during tests.
Related errors
- Could not find ${BUILDER_BASE_CLASS_NAME}#withJson(...); doe
- You must provide either a valid username/password pair for B
- Wasn't able to determine the distribution of the search serv
- Multiple extensions request different versions of Elasticsea
- Multiple extensions request different distributions of Elast
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/608a122b100e71e7.
Report an issue: GitHub.