public GroupShardsIterator activePrimaryShardsGrouped(String[] indices,boolean includeEmpty){
  ArrayList<ShardIterator> set=new ArrayList<>();
  for (  String index : indices) {
    IndexRoutingTable indexRoutingTable=index(index);
    if (indexRoutingTable == null) {
      throw new IndexNotFoundException(index);
    }
    for (    IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) {
      ShardRouting primary=indexShardRoutingTable.primaryShard();
      if (primary.active()) {
        set.add(primary.shardsIt());
      }
 else       if (includeEmpty) {
        set.add(new PlainShardIterator(primary.shardId(),Collections.<ShardRouting>emptyList()));
      }
    }
  }
  return new GroupShardsIterator(set);
}

public GroupShardsIterator activePrimaryShardsGrouped ( String [ ] indices , boolean includeEmpty ) { ArrayList < ShardIterator > set = new ArrayList < > ( ) ; for ( String index : indices ) { IndexRoutingTable indexRoutingTable = index ( index ) ; if ( indexRoutingTable == null ) { throw new IndexNotFoundException ( index ) ; } for ( IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable ) { ShardRouting primary = indexShardRoutingTable . primaryShard ( ) ; if ( primary . active ( ) ) { set . add ( primary . shardsIt ( ) ) ; } else if ( includeEmpty ) { set . add ( new PlainShardIterator ( primary . shardId ( ) , Collections . < ShardRouting > emptyList ( ) ) ) ; } } } return new GroupShardsIterator ( set ) ; }
all the * active * primary shards for the provided indices grouped ( each group is a single element , consisting of the primary shard ) . this is handy for components that expect to get group iterators , but still want in some cases to iterate over all primary shards ( and not just one shard in replication group ) .
