diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index 9662c4ca0fd2a..39cc586118eb5 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -720,11 +720,14 @@ private void performInferenceAndExecute(BulkShardRequest bulkShardRequest, Clust Map> fieldsForModels = clusterState.metadata() .index(bulkShardRequest.shardId().getIndex()) .getFieldsForModels(); + // No inference fields? Just execute the request if (fieldsForModels.isEmpty()) { executeBulkShardRequest(bulkShardRequest, releaseOnFinish); } Runnable onInferenceComplete = () -> { + // We need to remove items that have had an inference error, as the response will have been updated already + // and we don't need to process them further BulkShardRequest errorsFilteredShardRequest = new BulkShardRequest( bulkShardRequest.shardId(), bulkRequest.getRefreshPolicy(),