Search in sources :

Example 76 with Version

use of org.elasticsearch.Version in project elasticsearch by elastic.

the class AnalysisRegistryTests method testBackCompatOverrideDefaultIndexAnalyzer.

public void testBackCompatOverrideDefaultIndexAnalyzer() {
    Version version = VersionUtils.randomVersionBetween(random(), VersionUtils.getFirstVersion(), VersionUtils.getPreviousVersion(Version.V_5_0_0_alpha1));
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    IndexAnalyzers indexAnalyzers = registry.build(IndexSettingsModule.newIndexSettings("index", settings), singletonMap("default_index", analyzerProvider("default_index")), emptyMap(), emptyMap(), emptyMap(), emptyMap());
    assertThat(indexAnalyzers.getDefaultIndexAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class));
    assertThat(indexAnalyzers.getDefaultSearchAnalyzer().analyzer(), instanceOf(StandardAnalyzer.class));
    assertThat(indexAnalyzers.getDefaultSearchQuoteAnalyzer().analyzer(), instanceOf(StandardAnalyzer.class));
    assertWarnings("setting [index.analysis.analyzer.default_index] is deprecated, use [index.analysis.analyzer.default] " + "instead for index [index]");
}
Also used : Version(org.elasticsearch.Version) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) EnglishAnalyzer(org.apache.lucene.analysis.en.EnglishAnalyzer) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings)

Example 77 with Version

use of org.elasticsearch.Version in project elasticsearch by elastic.

the class AnalysisRegistryTests method testNoTypeOrTokenizerErrorMessage.

public void testNoTypeOrTokenizerErrorMessage() throws IOException {
    Version version = VersionUtils.randomVersion(random());
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).putArray("index.analysis.analyzer.test_analyzer.filter", new String[] { "lowercase", "stop", "shingle" }).putArray("index.analysis.analyzer.test_analyzer.char_filter", new String[] { "html_strip" }).build();
    IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);
    IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new AnalysisRegistry(new Environment(settings), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap()).build(idxSettings));
    assertThat(e.getMessage(), equalTo("analyzer [test_analyzer] must specify either an analyzer type, or a tokenizer"));
}
Also used : Version(org.elasticsearch.Version) IndexSettings(org.elasticsearch.index.IndexSettings) Environment(org.elasticsearch.env.Environment) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings)

Example 78 with Version

use of org.elasticsearch.Version in project elasticsearch by elastic.

the class AnalysisRegistryTests method testOverrideDefaultIndexAnalyzerIsUnsupported.

public void testOverrideDefaultIndexAnalyzerIsUnsupported() {
    Version version = VersionUtils.randomVersionBetween(random(), Version.V_5_0_0_alpha1, Version.CURRENT);
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    AnalyzerProvider<?> defaultIndex = new PreBuiltAnalyzerProvider("default_index", AnalyzerScope.INDEX, new EnglishAnalyzer());
    IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> registry.build(IndexSettingsModule.newIndexSettings("index", settings), singletonMap("default_index", defaultIndex), emptyMap(), emptyMap(), emptyMap(), emptyMap()));
    assertTrue(e.getMessage().contains("[index.analysis.analyzer.default_index] is not supported"));
}
Also used : Version(org.elasticsearch.Version) EnglishAnalyzer(org.apache.lucene.analysis.en.EnglishAnalyzer) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings)

Example 79 with Version

use of org.elasticsearch.Version in project elasticsearch by elastic.

the class AnalysisRegistryTests method testOverrideDefaultAnalyzer.

public void testOverrideDefaultAnalyzer() throws IOException {
    Version version = VersionUtils.randomVersion(random());
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    IndexAnalyzers indexAnalyzers = registry.build(IndexSettingsModule.newIndexSettings("index", settings), singletonMap("default", analyzerProvider("default")), emptyMap(), emptyMap(), emptyMap(), emptyMap());
    assertThat(indexAnalyzers.getDefaultIndexAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class));
    assertThat(indexAnalyzers.getDefaultSearchAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class));
    assertThat(indexAnalyzers.getDefaultSearchQuoteAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class));
}
Also used : Version(org.elasticsearch.Version) EnglishAnalyzer(org.apache.lucene.analysis.en.EnglishAnalyzer) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings)

Example 80 with Version

use of org.elasticsearch.Version in project elasticsearch by elastic.

the class AnalysisRegistryTests method testBackCompatOverrideDefaultIndexAndSearchAnalyzer.

public void testBackCompatOverrideDefaultIndexAndSearchAnalyzer() {
    Version version = VersionUtils.randomVersionBetween(random(), VersionUtils.getFirstVersion(), VersionUtils.getPreviousVersion(Version.V_5_0_0_alpha1));
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    Map<String, AnalyzerProvider<?>> analyzers = new HashMap<>();
    analyzers.put("default_index", analyzerProvider("default_index"));
    analyzers.put("default_search", analyzerProvider("default_search"));
    IndexAnalyzers indexAnalyzers = registry.build(IndexSettingsModule.newIndexSettings("index", settings), analyzers, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap());
    assertThat(indexAnalyzers.getDefaultIndexAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class));
    assertThat(indexAnalyzers.getDefaultSearchAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class));
    assertThat(indexAnalyzers.getDefaultSearchQuoteAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class));
    assertWarnings("setting [index.analysis.analyzer.default_index] is deprecated, use [index.analysis.analyzer.default] " + "instead for index [index]");
}
Also used : Version(org.elasticsearch.Version) HashMap(java.util.HashMap) EnglishAnalyzer(org.apache.lucene.analysis.en.EnglishAnalyzer) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings)

Aggregations

Version (org.elasticsearch.Version)124 Settings (org.elasticsearch.common.settings.Settings)51 StreamInput (org.elasticsearch.common.io.stream.StreamInput)21 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)20 HashMap (java.util.HashMap)17 ArrayList (java.util.ArrayList)16 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)16 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)14 IOException (java.io.IOException)13 SearchResponse (org.elasticsearch.action.search.SearchResponse)12 List (java.util.List)11 Map (java.util.Map)11 ClusterState (org.elasticsearch.cluster.ClusterState)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 ClusterName (org.elasticsearch.cluster.ClusterName)9 TimeValue (org.elasticsearch.common.unit.TimeValue)9 VersionUtils.randomVersion (org.elasticsearch.test.VersionUtils.randomVersion)9 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)8 CompressedXContent (org.elasticsearch.common.compress.CompressedXContent)8 GeoPoint (org.elasticsearch.common.geo.GeoPoint)8