}
final ImmutableMap.Builder<String, Object> result = ImmutableMap.builder();
try {
final IndexStatistics stats = indices.getIndexStats(index);
if (stats == null) {
LOG.error("Index [{}] not found.", index);
return Response.status(404).build();
}
final ImmutableList.Builder<Map<String, Object>> routing = ImmutableList.builder();
for (ShardRouting shardRouting : stats.getShardRoutings()) {
routing.add(shardRouting(shardRouting));
}
result.put("primary_shards", indexStats(stats.getPrimaries()));
result.put("all_shards", indexStats(stats.getTotal()));
result.put("routing", routing.build());
result.put("is_reopened", indices.isReopened(index));
} catch (Exception e) {
LOG.error("Could not get indices information.", e);
return Response.serverError().build();