}
else {
Set<Class> involvedClasses = new HashSet<Class>( classes.length );
Collections.addAll( involvedClasses, classes );
for (Class clazz : classes) {
DocumentBuilder builder = builders.get( clazz );
if ( builder != null ) involvedClasses.addAll( builder.getMappedSubclasses() );
}
for (Class clazz : involvedClasses) {
DocumentBuilder builder = builders.get( clazz );
//TODO should we rather choose a polymorphic path and allow non mapped entities
if ( builder == null )
throw new HibernateException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy().getDirectoryProvidersForAllShards();
searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
populateDirectories( directories, directoryProviders, searchFactoryImplementor );
}
classesAndSubclasses = involvedClasses;
}