From 33915aefd89c736df1c56251365fdf5658229998 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Thu, 9 Feb 2017 18:59:49 +0200 Subject: [PATCH] Improve BulkShardRequest.toString when it has only 1 internal request Now that we use bulk for single item indexing, this is often the case. Having an indicator of the id of the indexed document helps debugging. It now looks like this `BulkShardRequest to [[test][0]] containing [index {[test][type][AVojzy9ZxfWASZ-ysmN7], source[{"auto":true}]}]` --- .../elasticsearch/action/bulk/BulkShardRequest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java index d53e9f8997e..c270c51ea38 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java @@ -85,8 +85,14 @@ public class BulkShardRequest extends ReplicatedWriteRequest { @Override public String toString() { // This is included in error messages so we'll try to make it somewhat user friendly. - StringBuilder b = new StringBuilder("BulkShardRequest to ["); - b.append(index).append("] containing [").append(items.length).append("] requests"); + StringBuilder b = new StringBuilder("BulkShardRequest ["); + b.append(shardId).append("] containing ["); + if (items.length > 1) { + b.append(items.length).append("] requests"); + } else { + b.append(items[0].request()).append("]"); + } + switch (getRefreshPolicy()) { case IMMEDIATE: b.append(" and a refresh");