private SearchFactoryIntegrator getSearchFactory(Properties indexingProperties, ComponentRegistry cr) {
SearchFactoryIntegrator searchFactory = cr.getComponent(SearchFactoryIntegrator.class);
//defend against multiple initialization:
if (searchFactory==null) {
// Set up the search factory for Hibernate Search first.
SearchConfiguration config = new SearchableCacheConfiguration(new Class[0], indexingProperties);
searchFactory = new SearchFactoryBuilder().configuration(config).buildSearchFactory();
cr.registerComponent(searchFactory, SearchFactoryIntegrator.class);
}
return searchFactory;
}