diff --git a/src/main/java/org/elasticsearch/indices/analysis/HunspellService.java b/src/main/java/org/elasticsearch/indices/analysis/HunspellService.java index 2e95c66f434..5fc191b928f 100644 --- a/src/main/java/org/elasticsearch/indices/analysis/HunspellService.java +++ b/src/main/java/org/elasticsearch/indices/analysis/HunspellService.java @@ -151,8 +151,7 @@ public class HunspellService extends AbstractComponent { if (logger.isDebugEnabled()) { logger.debug("Loading huspell dictionary [{}]...", locale); } - File hunspellConfDir = new File(env.configFile(), "hunspell"); - File dicDir = new File(hunspellConfDir, locale); + File dicDir = new File(hunspellDir, locale); if (!dicDir.exists() || !dicDir.isDirectory()) { throw new ElasticSearchException(String.format("Could not find hunspell dictionary [%s]", locale)); } diff --git a/src/test/java/org/elasticsearch/test/integration/indices/analyze/HunspellServiceTests.java b/src/test/java/org/elasticsearch/test/integration/indices/analyze/HunspellServiceTests.java index dd3d1dba4df..5d3563c670c 100644 --- a/src/test/java/org/elasticsearch/test/integration/indices/analyze/HunspellServiceTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indices/analyze/HunspellServiceTests.java @@ -89,4 +89,16 @@ public class HunspellServiceTests extends AbstractNodesTests { assertThat(dictionary.isIgnoreCase(), equalTo(true)); } + @Test + public void testCustomizeLocaleDirectory() throws Exception { + Settings settings = ImmutableSettings.settingsBuilder() + .put("indices.analysis.hunspell.dictionary.location", getClass().getResource("/indices/analyze/conf_dir/hunspell").getFile()) + .build(); + + Node node = startNode("node1", settings); + + HunspellDictionary dictionary = ((InternalNode) node).injector().getInstance(HunspellService.class).getDictionary("en_US"); + assertThat(dictionary, notNullValue()); + } + }