@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(PROFILE_FIELD).startArray(SHARDS_FIELD); // shardResults is a map, but we print entries in a json array, which is ordered. // we sort the keys of the map, so that toXContent always prints out the same array order TreeSet<String> sortedKeys = new TreeSet<>(shardResults.keySet()); for (String key : sortedKeys) { builder.startObject(); builder.field(ID_FIELD, key); builder.startArray(SEARCHES_FIELD); ProfileShardResult profileShardResult = shardResults.get(key); for (QueryProfileShardResult result : profileShardResult.getQueryProfileResults()) { result.toXContent(builder, params); } builder.endArray(); profileShardResult.getAggregationProfileResults().toXContent(builder, params); builder.endObject(); } builder.endArray().endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(PROFILE_FIELD).startArray(SHARDS_FIELD); // shardResults is a map, but we print entries in a json array, which is ordered. // we sort the keys of the map, so that toXContent always prints out the same array order TreeSet<String> sortedKeys = new TreeSet<>(shardResults.keySet()); for (String key : sortedKeys) { builder.startObject(); builder.field(ID_FIELD, key); builder.startArray(SEARCHES_FIELD); ProfileShardResult profileShardResult = shardResults.get(key); for (QueryProfileShardResult result : profileShardResult.getQueryProfileResults()) { result.toXContent(builder, params); } builder.endArray(); profileShardResult.getAggregationProfileResults().toXContent(builder, params); builder.endObject(); } builder.endArray().endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(PROFILE_FIELD).startArray(SHARDS_FIELD); // shardResults is a map, but we print entries in a json array, which is ordered. // we sort the keys of the map, so that toXContent always prints out the same array order TreeSet<String> sortedKeys = new TreeSet<>(shardResults.keySet()); for (String key : sortedKeys) { builder.startObject(); builder.field(ID_FIELD, key); builder.startArray(SEARCHES_FIELD); ProfileShardResult profileShardResult = shardResults.get(key); for (QueryProfileShardResult result : profileShardResult.getQueryProfileResults()) { result.toXContent(builder, params); } builder.endArray(); profileShardResult.getAggregationProfileResults().toXContent(builder, params); builder.endObject(); } builder.endArray().endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(PROFILE_FIELD).startArray(SHARDS_FIELD); // shardResults is a map, but we print entries in a json array, which is ordered. // we sort the keys of the map, so that toXContent always prints out the same array order TreeSet<String> sortedKeys = new TreeSet<>(shardResults.keySet()); for (String key : sortedKeys) { builder.startObject(); builder.field(ID_FIELD, key); builder.startArray(SEARCHES_FIELD); ProfileShardResult profileShardResult = shardResults.get(key); for (QueryProfileShardResult result : profileShardResult.getQueryProfileResults()) { result.toXContent(builder, params); } builder.endArray(); profileShardResult.getAggregationProfileResults().toXContent(builder, params); builder.endObject(); } builder.endArray().endObject(); return builder; }