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}]}]`
@@ -85,8 +85,14 @@ public class BulkShardRequest extends ReplicatedWriteRequest<BulkShardRequest> {
@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");
