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<?>, EntityIndexBinding> documentBuildersIndexedEntities = factoryState.getIndexBindings();
for ( Entry<Class<?>, EntityIndexBinding> entry : documentBuildersIndexedEntities.entrySet() ) {
Class<?> clazz = entry.getKey();
EntityIndexBinding entityIndexBinding = entry.getValue();
Similarity entitySimilarity = entityIndexBinding.getSimilarity();
if ( entitySimilarity == null ) {
//might have been read from annotations, fill the missing information in the EntityIndexBinder:
entitySimilarity = entityIndexBinding.getDocumentBuilder().getSimilarity();
if ( entitySimilarity != null ) {
MutableEntityIndexBinding<?> newMapping = buildTypeSafeMutableEntityBinder(
entityIndexBinding,
entitySimilarity
);
entityIndexBinding = newMapping;
documentBuildersIndexedEntities.put( clazz, entityIndexBinding );
}
}
IndexManager[] indexManagers = entityIndexBinding.getIndexManagers();
for ( IndexManager indexManager : indexManagers ) {
Similarity indexSimilarity = indexManager.getSimilarity();
if ( entitySimilarity != null && indexSimilarity == null ) {
indexManager.setSimilarity( entitySimilarity );
}