@Override
  public IndexReader open(Class<?>... entities) {
    if (entities.length == 0) {
      throw log.needAtLeastOneIndexedEntityType();
    }

    HashMap<String, IndexManager> indexManagers = new HashMap<String, IndexManager>();
    for (Class<?> type : entities) {
      EntityIndexBinding entityIndexBinding = searchFactory.getSafeIndexBindingForEntity(type);
      IndexManager[] indexManagersForAllShards =
          entityIndexBinding.getSelectionStrategy().getIndexManagersForAllShards();
      for (IndexManager im : indexManagersForAllShards) {
        indexManagers.put(im.getIndexName(), im);
      }
    }
    IndexManager[] uniqueIndexManagers =
        indexManagers.values().toArray(new IndexManager[indexManagers.size()]);
    return MultiReaderFactory.openReader(uniqueIndexManagers);
  }
 @Override
 public IndexReader open(String... indexNames) {
   TreeSet<String> names = new TreeSet<String>();
   for (String name : indexNames) {
     if (name != null) {
       names.add(name);
     }
   }
   final int size = names.size();
   if (size == 0) {
     throw log.needAtLeastOneIndexName();
   }
   String[] indexManagerNames = names.toArray(new String[size]);
   IndexManagerHolder managerSource = searchFactory.getIndexManagerHolder();
   IndexManager[] managers = new IndexManager[size];
   for (int i = 0; i < size; i++) {
     String indexName = indexManagerNames[i];
     managers[i] = managerSource.getIndexManager(indexName);
     if (managers[i] == null) {
       throw log.requestedIndexNotDefined(indexName);
     }
   }
   return MultiReaderFactory.openReader(managers);
 }