- /**
- * Contains all of the predefined indexing filters.
- */
- private FilterSchema[] customFilters;
-
- /**
- * Contains all of the predefined indexing analyzers.
- */
- private AnalyzerSchema[] customAnalysers;
-
- /**
- * Indicates whether or not we have imported the filter and
- * analyzer configurations.
- */
- private AtomicBoolean configured = new AtomicBoolean(false);
-
- /**
- * A json format string which is readable by Elastic Search and defines
- * all of the custom filters and analyzers that we need Elastic Search
- * to know about.
- */
- private static String esSettings = null;
-
- private static Logger logger = LoggerFactory.getInstance()
- .getLogger(AnalysisConfiguration.class.getName());
-
-
- /**
- * Imports the filter and analyzer configuration files and
- * builds an Elastic Search readable settings file from the
- * contents.
- *
- * @param filterConfigFile - Location of filter configuration json file
- * @param analyzerConfigFile - Location of analyzer configuration json file
- */
- public void init(String filterConfigFile, String analyzerConfigFile) {
-
- if (configured.compareAndSet(false, true)) {
- ObjectMapper mapper = new ObjectMapper();
-
- File filtersConfig = new File(filterConfigFile);
- try {
- customFilters = mapper.readValue(filtersConfig, FilterSchema[].class);
- } catch (IOException e) {
-
- // generate log
- logger.warn(SearchDbMsgs.FILTERS_CONFIG_FAILURE, filterConfigFile, e.getMessage());
- }
-
- File analysersConfig = new File(analyzerConfigFile);
- try {
- customAnalysers = mapper.readValue(analysersConfig, AnalyzerSchema[].class);
- } catch (IOException e) {
-
- // generate log
- logger.warn(SearchDbMsgs.ANALYSYS_CONFIG_FAILURE, analyzerConfigFile, e.getMessage());
- }
-
- esSettings = buildEsIndexSettings();
+ /**
+ * Contains all of the predefined indexing filters.
+ */
+ private FilterSchema[] customFilters;
+
+ /**
+ * Contains all of the predefined indexing analyzers.
+ */
+ private AnalyzerSchema[] customAnalysers;
+
+ /**
+ * Indicates whether or not we have imported the filter and analyzer configurations.
+ */
+ private AtomicBoolean configured = new AtomicBoolean(false);
+
+ /**
+ * A json format string which is readable by Elastic Search and defines all of the custom filters and analyzers that
+ * we need Elastic Search to know about.
+ */
+ private String esSettings = null;
+
+ private static Logger logger = LoggerFactory.getInstance().getLogger(AnalysisConfiguration.class.getName());
+
+
+ /**
+ * Imports the filter and analyzer configuration files and builds an Elastic Search readable settings file from the
+ * contents.
+ *
+ * @param filterConfigFile - Location of filter configuration json file
+ * @param analyzerConfigFile - Location of analyzer configuration json file
+ */
+ public void init(String filterConfigFile, String analyzerConfigFile) {
+
+ if (configured.compareAndSet(false, true)) {
+ ObjectMapper mapper = new ObjectMapper();
+
+ File filtersConfig = new File(filterConfigFile);
+ try {
+ customFilters = mapper.readValue(filtersConfig, FilterSchema[].class);
+ } catch (IOException e) {
+
+ // generate log
+ logger.warn(SearchDbMsgs.FILTERS_CONFIG_FAILURE, filterConfigFile, e.getMessage());
+ }
+
+ File analysersConfig = new File(analyzerConfigFile);
+ try {
+ customAnalysers = mapper.readValue(analysersConfig, AnalyzerSchema[].class);
+ } catch (IOException e) {
+
+ // generate log
+ logger.warn(SearchDbMsgs.ANALYSYS_CONFIG_FAILURE, analyzerConfigFile, e.getMessage());
+ }
+
+ esSettings = buildEsIndexSettings();
+ }
+ }
+
+
+ /**
+ * Returns the set of pre-configured filters.
+ *
+ * @return - An array of filters.
+ */
+ public FilterSchema[] getFilters() {
+ return customFilters;
+ }
+
+
+ /**
+ * Returns the set of pre-configured analyzers.
+ *
+ * @return - An array of analyzers.
+ */
+ public AnalyzerSchema[] getAnalyzers() {
+ init(SearchDbConstants.SDB_FILTER_CONFIG_FILE, SearchDbConstants.SDB_ANALYSIS_CONFIG_FILE);
+ return customAnalysers;
+ }
+
+
+ /**
+ * Imports the filter and analyzer configurations and translates those into a settings string that will be parseable
+ * by Elastic Search.
+ *
+ * @return - Elastic Search formatted settings string.
+ */
+ public String getEsIndexSettings() {
+
+ // Generate the es-settings string from our filter and analyzer
+ // configurations if we have not already done so.
+ init(SearchDbConstants.SDB_FILTER_CONFIG_FILE, SearchDbConstants.SDB_ANALYSIS_CONFIG_FILE);
+
+ // Now, return the es-settings string.
+ return esSettings;