Fixed custom hunspell dictionary directory

Properly loading dictionaries from based on the "indices.analysis.hunspell.dictionary.location" setting if one exists
This commit is contained in:
uboness 2013-05-07 17:21:37 +02:00
parent e1b66b34ea
commit 74317fec8b
2 changed files with 13 additions and 2 deletions

View File

@ -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));
}

View File

@ -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());
}
}