|
@@ -31,6 +31,7 @@ import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|
|
import org.elasticsearch.common.inject.Injector;
|
|
import org.elasticsearch.common.inject.Injector;
|
|
|
import org.elasticsearch.common.inject.ModulesBuilder;
|
|
import org.elasticsearch.common.inject.ModulesBuilder;
|
|
|
|
|
+import org.elasticsearch.common.inject.ProvisionException;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.settings.SettingsModule;
|
|
import org.elasticsearch.common.settings.SettingsModule;
|
|
|
import org.elasticsearch.env.Environment;
|
|
import org.elasticsearch.env.Environment;
|
|
@@ -94,7 +95,7 @@ public class AnalysisModuleTests extends ElasticsearchTestCase {
|
|
|
Settings settings = loadFromClasspath("org/elasticsearch/index/analysis/test1.yml");
|
|
Settings settings = loadFromClasspath("org/elasticsearch/index/analysis/test1.yml");
|
|
|
testSimpleConfiguration(settings);
|
|
testSimpleConfiguration(settings);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Test
|
|
@Test
|
|
|
public void testDefaultFactoryTokenFilters() throws IOException {
|
|
public void testDefaultFactoryTokenFilters() throws IOException {
|
|
|
assertTokenFilter("keyword_repeat", KeywordRepeatFilter.class);
|
|
assertTokenFilter("keyword_repeat", KeywordRepeatFilter.class);
|
|
@@ -238,4 +239,36 @@ public class AnalysisModuleTests extends ElasticsearchTestCase {
|
|
|
return wordListFile;
|
|
return wordListFile;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void testUnderscoreInAnalyzerName() {
|
|
|
|
|
+ Settings settings = Settings.builder()
|
|
|
|
|
+ .put("index.analysis.analyzer._invalid_name.tokenizer", "keyword")
|
|
|
|
|
+ .put("path.home", createTempDir().toString())
|
|
|
|
|
+ .put(IndexMetaData.SETTING_VERSION_CREATED, "1")
|
|
|
|
|
+ .build();
|
|
|
|
|
+ try {
|
|
|
|
|
+ getAnalysisService(settings);
|
|
|
|
|
+ fail("This should fail with IllegalArgumentException because the analyzers name starts with _");
|
|
|
|
|
+ } catch (ProvisionException e) {
|
|
|
|
|
+ assertTrue(e.getCause() instanceof IllegalArgumentException);
|
|
|
|
|
+ assertThat(e.getCause().getMessage(), equalTo("analyzer name must not start with _. got \"_invalid_name\""));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void testUnderscoreInAnalyzerNameAlias() {
|
|
|
|
|
+ Settings settings = Settings.builder()
|
|
|
|
|
+ .put("index.analysis.analyzer.valid_name.tokenizer", "keyword")
|
|
|
|
|
+ .put("index.analysis.analyzer.valid_name.alias", "_invalid_name")
|
|
|
|
|
+ .put("path.home", createTempDir().toString())
|
|
|
|
|
+ .put(IndexMetaData.SETTING_VERSION_CREATED, "1")
|
|
|
|
|
+ .build();
|
|
|
|
|
+ try {
|
|
|
|
|
+ getAnalysisService(settings);
|
|
|
|
|
+ fail("This should fail with IllegalArgumentException because the analyzers alias starts with _");
|
|
|
|
|
+ } catch (ProvisionException e) {
|
|
|
|
|
+ assertTrue(e.getCause() instanceof IllegalArgumentException);
|
|
|
|
|
+ assertThat(e.getCause().getMessage(), equalTo("analyzer name must not start with _. got \"_invalid_name\""));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|