/**
  * Primaries.
  *
  * @return the common stats
  */
 public CommonStats primaries() {
   if (primary != null) {
     return primary;
   }
   CommonStats stats = new CommonStats();
   for (ShardStats shard : shards) {
     if (shard.shardRouting().primary()) {
       stats.add(shard.stats());
     }
   }
   primary = stats;
   return stats;
 }
 /**
  * Index shards.
  *
  * @return the map
  */
 public Map<Integer, IndexShardStats> indexShards() {
   if (indexShards != null) {
     return indexShards;
   }
   Map<Integer, List<ShardStats>> tmpIndexShards = Maps.newHashMap();
   for (ShardStats shard : shards) {
     List<ShardStats> lst = tmpIndexShards.get(shard.shardRouting().id());
     if (lst == null) {
       lst = Lists.newArrayList();
       tmpIndexShards.put(shard.shardRouting().id(), lst);
     }
     lst.add(shard);
   }
   indexShards = Maps.newHashMap();
   for (Map.Entry<Integer, List<ShardStats>> entry : tmpIndexShards.entrySet()) {
     indexShards.put(
         entry.getKey(),
         new IndexShardStats(
             entry.getValue().get(0).shardRouting().shardId(),
             entry.getValue().toArray(new ShardStats[entry.getValue().size()])));
   }
   return indexShards;
 }