diff --git a/src/main/java/org/elasticsearch/common/Strings.java b/src/main/java/org/elasticsearch/common/Strings.java index 40d962223be..3c001fe28fe 100644 --- a/src/main/java/org/elasticsearch/common/Strings.java +++ b/src/main/java/org/elasticsearch/common/Strings.java @@ -1293,10 +1293,13 @@ public class Strings { * @return the delimited String */ public static String collectionToDelimitedString(Iterable coll, String delim, String prefix, String suffix) { + return collectionToDelimitedString(coll, delim, prefix, suffix, new StringBuilder()); + } + + public static String collectionToDelimitedString(Iterable coll, String delim, String prefix, String suffix, StringBuilder sb) { if (Iterables.isEmpty(coll)) { return ""; } - StringBuilder sb = new StringBuilder(); Iterator it = coll.iterator(); while (it.hasNext()) { sb.append(prefix).append(it.next()).append(suffix); @@ -1339,10 +1342,13 @@ public class Strings { * @return the delimited String */ public static String arrayToDelimitedString(Object[] arr, String delim) { + return arrayToDelimitedString(arr, delim, new StringBuilder()); + } + + public static String arrayToDelimitedString(Object[] arr, String delim, StringBuilder sb) { if (isEmpty(arr)) { return ""; } - StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.length; i++) { if (i > 0) { sb.append(delim); diff --git a/src/main/java/org/elasticsearch/index/search/slowlog/ShardSlowLogSearchService.java b/src/main/java/org/elasticsearch/index/search/slowlog/ShardSlowLogSearchService.java index 5ddc7f35e64..aa394a9ad0e 100644 --- a/src/main/java/org/elasticsearch/index/search/slowlog/ShardSlowLogSearchService.java +++ b/src/main/java/org/elasticsearch/index/search/slowlog/ShardSlowLogSearchService.java @@ -20,6 +20,7 @@ package org.elasticsearch.index.search.slowlog; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; @@ -188,6 +189,20 @@ public class ShardSlowLogSearchService extends AbstractIndexShardComponent { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("took[").append(TimeValue.timeValueNanos(tookInNanos)).append("], took_millis[").append(TimeUnit.NANOSECONDS.toMillis(tookInNanos)).append("], "); + if (context.types() == null) { + sb.append("types[], "); + } else { + sb.append("types["); + Strings.arrayToDelimitedString(context.types(), ",", sb); + sb.append("], "); + } + if (context.groupStats() == null) { + sb.append("stats[], "); + } else { + sb.append("stats["); + Strings.collectionToDelimitedString(context.groupStats(), ",", "", "", sb); + sb.append("], "); + } sb.append("search_type[").append(context.searchType()).append("], total_shards[").append(context.numberOfShards()).append("], "); if (context.request().source() != null && context.request().source().length() > 0) { try {