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 = buildTypeSafeMutableEntityBinder(
clazz,
entityMapping,
entitySimilarity
);
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 );
}