public Map<String, IndexSegments> getIndices() { if (indicesSegments != null) { return indicesSegments; } Map<String, IndexSegments> indicesSegments = Maps.newHashMap(); Set<String> indices = Sets.newHashSet(); for (ShardSegments shard : shards) { indices.add(shard.getIndex()); } for (String index : indices) { List<ShardSegments> shards = Lists.newArrayList(); for (ShardSegments shard : this.shards) { if (shard.getShardRouting().index().equals(index)) { shards.add(shard); } } indicesSegments.put( index, new IndexSegments(index, shards.toArray(new ShardSegments[shards.size()]))); } this.indicesSegments = indicesSegments; return indicesSegments; }