use of org.elasticsearch.indices.analysis.HunspellService in project elasticsearch by elastic.
the class HunspellServiceTests method testLocaleDirectoryWithNodeLevelConfig.
public void testLocaleDirectoryWithNodeLevelConfig() throws Exception {
Settings settings = Settings.builder().put(Environment.PATH_CONF_SETTING.getKey(), getDataPath("/indices/analyze/conf_dir")).put(HUNSPELL_LAZY_LOAD.getKey(), randomBoolean()).put(HUNSPELL_IGNORE_CASE.getKey(), true).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
Dictionary dictionary = new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US");
assertThat(dictionary, notNullValue());
assertTrue(dictionary.getIgnoreCase());
}
use of org.elasticsearch.indices.analysis.HunspellService in project elasticsearch by elastic.
the class HunspellServiceTests method testDicWithTwoAffs.
public void testDicWithTwoAffs() throws Exception {
Settings settings = Settings.builder().put(Environment.PATH_CONF_SETTING.getKey(), getDataPath("/indices/analyze/two_aff_conf_dir")).put(HUNSPELL_LAZY_LOAD.getKey(), randomBoolean()).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
IllegalStateException e = expectThrows(IllegalStateException.class, () -> new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US"));
assertEquals("failed to load hunspell dictionary for locale: en_US", e.getMessage());
assertThat(e.getCause(), hasToString(containsString("Too many affix files")));
}
use of org.elasticsearch.indices.analysis.HunspellService in project elasticsearch by elastic.
the class HunspellServiceTests method testLocaleDirectoryWithLocaleSpecificConfig.
public void testLocaleDirectoryWithLocaleSpecificConfig() throws Exception {
Settings settings = Settings.builder().put(Environment.PATH_CONF_SETTING.getKey(), getDataPath("/indices/analyze/conf_dir")).put(HUNSPELL_LAZY_LOAD.getKey(), randomBoolean()).put(HUNSPELL_IGNORE_CASE.getKey(), true).put("indices.analysis.hunspell.dictionary.en_US.strict_affix_parsing", false).put("indices.analysis.hunspell.dictionary.en_US.ignore_case", false).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
Dictionary dictionary = new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US");
assertThat(dictionary, notNullValue());
assertFalse(dictionary.getIgnoreCase());
// testing that dictionary specific settings override node level settings
dictionary = new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US_custom");
assertThat(dictionary, notNullValue());
assertTrue(dictionary.getIgnoreCase());
}
use of org.elasticsearch.indices.analysis.HunspellService in project elasticsearch by elastic.
the class HunspellServiceTests method testDicWithNoAff.
public void testDicWithNoAff() throws Exception {
Settings settings = Settings.builder().put(Environment.PATH_CONF_SETTING.getKey(), getDataPath("/indices/analyze/no_aff_conf_dir")).put(HUNSPELL_LAZY_LOAD.getKey(), randomBoolean()).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
IllegalStateException e = expectThrows(IllegalStateException.class, () -> new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US"));
assertEquals("failed to load hunspell dictionary for locale: en_US", e.getMessage());
assertThat(e.getCause(), hasToString(containsString("Missing affix file")));
}
Aggregations