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}]}]`
This commit is contained in:
Boaz Leskes 2017-02-09 18:59:49 +02:00
parent 90ea778c17
commit 33915aefd8
1 changed files with 8 additions and 2 deletions

View File

@ -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");