All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.search.mapper.mapping.impl.IndexProperties Maven / Gradle / Ivy

package org.infinispan.search.mapper.mapping.impl;

import java.util.HashMap;
import java.util.Map;

import org.hibernate.search.engine.cfg.ConfigurationPropertySource;
import org.hibernate.search.engine.cfg.EngineSettings;
import org.hibernate.search.engine.cfg.spi.AllAwareConfigurationPropertySource;
import org.hibernate.search.engine.cfg.spi.ConfigurationPropertyChecker;

/**
 * @author Fabio Massimo Ercoli
 */
public class IndexProperties {

   private final Map engineProperties = new HashMap<>();
   private final Map backendProperties = new HashMap<>();

   public void setProperty(String key, Object value) {
      if (key.startsWith(EngineSettings.PREFIX)) {
         // engine properties are passed to Search as they are,
         // so they start with "hibernate.search."
         engineProperties.put(key, value);
      } else {
         // backend properties are passed with BACKEND_PROPERTIES_PREFIX,
         // so that the user doesn't need to set it for them
         backendProperties.put(key, value);
      }
   }

   public void setProperties(Map properties) {
      properties.forEach(this::setProperty);
   }

   public ConfigurationPropertySource createPropertySource(ConfigurationPropertyChecker propertyChecker) {
      ConfigurationPropertySource basePropertySource =
            propertyChecker.wrap(AllAwareConfigurationPropertySource.fromMap(backendProperties))
                  .withPrefix(EngineSettings.BACKEND);
      ConfigurationPropertySource propertySource =
            basePropertySource.withOverride(AllAwareConfigurationPropertySource.fromMap(engineProperties));
      defaultProperties();
      return propertySource;
   }

   private void defaultProperties() {
      backendProperties.put("type", "lucene");
      backendProperties.put("analysis.configurer", new DefaultAnalysisConfigurer());
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy