private void fillSimilarityMapping() {
//TODO cleanup: this logic to select the Similarity is too complex, should likely be done in a previous phase
final Map<Class<?>, EntityIndexBinder> documentBuildersIndexedEntities = factoryState.getIndexBindingForEntity();
for ( Entry<Class<?>, EntityIndexBinder> entry : documentBuildersIndexedEntities.entrySet() ) {
Class<?> clazz = entry.getKey();
EntityIndexBinder entityMapping = entry.getValue();
Similarity entitySimilarity = entityMapping.getSimilarity();
if ( entitySimilarity == null ) {
//might have been read from annotations, fill the missing information in the EntityIndexBinder:
entitySimilarity = entityMapping.getDocumentBuilder().getSimilarity();
if ( entitySimilarity != null ) {
MutableEntityIndexBinding newMapping = new MutableEntityIndexBinding( entityMapping.getSelectionStrategy(), entitySimilarity, entityMapping.getIndexManagers() );
newMapping.setDocumentBuilderIndexedEntity( entityMapping.getDocumentBuilder() );
entityMapping = newMapping;
documentBuildersIndexedEntities.put( clazz, entityMapping );
}
}
IndexManager[] indexManagers = entityMapping.getIndexManagers();
for ( IndexManager indexManager : indexManagers ) {
Similarity indexSimilarity = indexManager.getSimilarity();
if ( entitySimilarity != null && indexSimilarity == null ) {
indexManager.setSimilarity( entitySimilarity );
}