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:
parent
e1b66b34ea
commit
74317fec8b
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue