From 0efcd9cb07b5d41b04deeb3c199e00bfdbb5cc55 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Thu, 25 Apr 2019 17:03:01 -0700 Subject: [PATCH 1/4] Cleanup versioned deprecations in analysis This commit removes versioned logic in analyzer creation that is no longer relevant for 8.0. --- .../common/CJKBigramFilterFactory.java | 10 +-- .../analysis/common/CommonAnalysisPlugin.java | 10 --- .../common/CommonGramsTokenFilterFactory.java | 10 +-- .../common/EdgeNGramTokenFilterFactory.java | 10 +-- .../common/FingerprintTokenFilterFactory.java | 10 +-- ...acyDelimitedPayloadTokenFilterFactory.java | 44 ------------- .../common/MultiplexerTokenFilterFactory.java | 27 +------- .../common/NGramTokenFilterFactory.java | 23 ++----- .../common/NGramTokenizerFactory.java | 14 ++--- .../StandardHtmlStripAnalyzerProvider.java | 63 ------------------- .../WordDelimiterGraphTokenFilterFactory.java | 10 +-- .../WordDelimiterTokenFilterFactory.java | 10 +-- .../common/CommonAnalysisPluginTests.java | 26 -------- .../common/SynonymsAnalysisTests.java | 45 ------------- .../IcuNormalizerTokenFilterFactory.java | 11 +--- .../analysis/PhoneticTokenFilterFactory.java | 10 +-- .../AnalysisPhoneticFactoryTests.java | 12 ---- .../analysis/PreConfiguredTokenFilter.java | 18 +----- 18 files changed, 21 insertions(+), 342 deletions(-) delete mode 100644 modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java delete mode 100644 modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StandardHtmlStripAnalyzerProvider.java diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java index a794c409e4ef4..afde17d9ad014 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java @@ -23,7 +23,6 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.cjk.CJKBigramFilter; import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute; -import org.elasticsearch.Version; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -99,14 +98,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { if (outputUnigrams) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + - "] cannot be used to parse synonyms"); - } - else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } return this; } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java index e05305a8ebd39..f095b766ee1d5 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java @@ -173,7 +173,6 @@ public Map>> getAn analyzers.put("fingerprint", FingerprintAnalyzerProvider::new); // TODO remove in 8.0 - analyzers.put("standard_html_strip", StandardHtmlStripAnalyzerProvider::new); analyzers.put("pattern", PatternAnalyzerProvider::new); analyzers.put("snowball", SnowballAnalyzerProvider::new); @@ -233,7 +232,6 @@ public Map> getTokenFilters() { filters.put("condition", requiresAnalysisSettings((i, e, n, s) -> new ScriptedConditionTokenFilterFactory(i, n, s, scriptService.get()))); filters.put("decimal_digit", DecimalDigitFilterFactory::new); - filters.put("delimited_payload_filter", LegacyDelimitedPayloadTokenFilterFactory::new); filters.put("delimited_payload", DelimitedPayloadTokenFilterFactory::new); filters.put("dictionary_decompounder", requiresAnalysisSettings(DictionaryCompoundWordTokenFilterFactory::new)); filters.put("dutch_stem", DutchStemTokenFilterFactory::new); @@ -376,14 +374,6 @@ public List getPreBuiltAnalyzerProviderFactorie public List getPreConfiguredCharFilters() { List filters = new ArrayList<>(); filters.add(PreConfiguredCharFilter.singleton("html_strip", false, HTMLStripCharFilter::new)); - filters.add(PreConfiguredCharFilter.singletonWithVersion("htmlStrip", false, (reader, version) -> { - if (version.onOrAfter(org.elasticsearch.Version.V_6_3_0)) { - deprecationLogger.deprecatedAndMaybeLog("htmlStrip_deprecation", - "The [htmpStrip] char filter name is deprecated and will be removed in a future version. " - + "Please change the filter name to [html_strip] instead."); - } - return new HTMLStripCharFilter(reader); - })); return filters; } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonGramsTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonGramsTokenFilterFactory.java index 933a02f74e755..a3283769972a5 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonGramsTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonGramsTokenFilterFactory.java @@ -24,7 +24,6 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.commongrams.CommonGramsFilter; import org.apache.lucene.analysis.commongrams.CommonGramsQueryFilter; -import org.elasticsearch.Version; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -68,14 +67,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - } - - return this; + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/EdgeNGramTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/EdgeNGramTokenFilterFactory.java index 128b3d1cf82dc..bdbf6498bce5d 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/EdgeNGramTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/EdgeNGramTokenFilterFactory.java @@ -23,7 +23,6 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter; import org.apache.lucene.analysis.reverse.ReverseStringFilter; -import org.elasticsearch.Version; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -87,13 +86,6 @@ public boolean breaksFastVectorHighlighter() { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } - else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - return this; - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/FingerprintTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/FingerprintTokenFilterFactory.java index 433fa4d7dee12..914c157324e2c 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/FingerprintTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/FingerprintTokenFilterFactory.java @@ -22,7 +22,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.FingerprintFilter; -import org.elasticsearch.Version; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -56,14 +55,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } - else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - return this; - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java deleted file mode 100644 index ae20a5fbf5a86..0000000000000 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.analysis.common; - -import org.apache.logging.log4j.LogManager; -import org.elasticsearch.Version; -import org.elasticsearch.common.logging.DeprecationLogger; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.env.Environment; -import org.elasticsearch.index.IndexSettings; - -public class LegacyDelimitedPayloadTokenFilterFactory extends DelimitedPayloadTokenFilterFactory { - - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(LegacyDelimitedPayloadTokenFilterFactory.class)); - - LegacyDelimitedPayloadTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { - super(indexSettings, env, name, settings); - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException( - "[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead"); - } - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_2_0)) { - deprecationLogger.deprecated("Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]"); - } - } -} diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java index 9c53fc1f63e3b..a20ed8c1e43f1 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java @@ -25,7 +25,6 @@ import org.apache.lucene.analysis.miscellaneous.ConditionalTokenFilter; import org.apache.lucene.analysis.miscellaneous.RemoveDuplicatesTokenFilter; import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; -import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; @@ -62,18 +61,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } - else { - if (preserveOriginal) { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - return IDENTITY_FILTER; - } - throw new IllegalArgumentException("Token filter [" + name() - + "] cannot be used to parse synonyms unless [preserve_original] is [true]"); - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } @Override @@ -120,18 +108,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } - else { - if (preserveOriginal) { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - return IDENTITY_FILTER; - } - throw new IllegalArgumentException("Token filter [" + name() - + "] cannot be used to parse synonyms unless [preserve_original] is [true]"); - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } }; } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java index 6abf2cbd37cb2..ab8d9e4d76e8d 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java @@ -27,7 +27,6 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.AbstractTokenFilterFactory; -import org.elasticsearch.Version; import org.elasticsearch.index.analysis.TokenFilterFactory; @@ -47,15 +46,10 @@ public class NGramTokenFilterFactory extends AbstractTokenFilterFactory { this.maxGram = settings.getAsInt("max_gram", 2); int ngramDiff = maxGram - minGram; if (ngramDiff > maxAllowedNgramDiff) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException( - "The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [" - + maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the [" - + IndexSettings.MAX_NGRAM_DIFF_SETTING.getKey() + "] index level setting."); - } else { - deprecationLogger.deprecated("Deprecated big difference between max_gram and min_gram in NGram Tokenizer," - + "expected difference must be less than or equal to: [" + maxAllowedNgramDiff + "]"); - } + throw new IllegalArgumentException( + "The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [" + + maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the [" + + IndexSettings.MAX_NGRAM_DIFF_SETTING.getKey() + "] index level setting."); } } @@ -67,13 +61,6 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } - else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - return this; - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java index e811d0fbc4bda..39ee16dd44b1a 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java @@ -21,7 +21,6 @@ import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.ngram.NGramTokenizer; -import org.elasticsearch.Version; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -91,15 +90,10 @@ static CharMatcher parseTokenChars(List characterClasses) { this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE); int ngramDiff = maxGram - minGram; if (ngramDiff > maxAllowedNgramDiff) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException( - "The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [" - + maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the [" - + IndexSettings.MAX_NGRAM_DIFF_SETTING.getKey() + "] index level setting."); - } else { - deprecationLogger.deprecated("Deprecated big difference between max_gram and min_gram in NGram Tokenizer," - + "expected difference must be less than or equal to: [" + maxAllowedNgramDiff + "]"); - } + throw new IllegalArgumentException( + "The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [" + + maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the [" + + IndexSettings.MAX_NGRAM_DIFF_SETTING.getKey() + "] index level setting."); } this.matcher = parseTokenChars(settings.getAsList("token_chars")); } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StandardHtmlStripAnalyzerProvider.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StandardHtmlStripAnalyzerProvider.java deleted file mode 100644 index 5dd475cc5e408..0000000000000 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StandardHtmlStripAnalyzerProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.analysis.common; - -import org.apache.logging.log4j.LogManager; -import org.apache.lucene.analysis.CharArraySet; -import org.elasticsearch.Version; -import org.elasticsearch.common.logging.DeprecationLogger; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.env.Environment; -import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider; -import org.elasticsearch.index.analysis.Analysis; - -public class StandardHtmlStripAnalyzerProvider extends AbstractIndexAnalyzerProvider { - - private static final DeprecationLogger DEPRECATION_LOGGER = - new DeprecationLogger(LogManager.getLogger(StandardHtmlStripAnalyzerProvider.class)); - - private final StandardHtmlStripAnalyzer analyzer; - - /** - * @deprecated in 6.5, can not create in 7.0, and we remove this in 8.0 - */ - @Deprecated - StandardHtmlStripAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) { - super(indexSettings, name, settings); - final CharArraySet defaultStopwords = CharArraySet.EMPTY_SET; - CharArraySet stopWords = Analysis.parseStopWords(env, settings, defaultStopwords); - analyzer = new StandardHtmlStripAnalyzer(stopWords); - analyzer.setVersion(version); - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("[standard_html_strip] analyzer is not supported for new indices, " + - "use a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter"); - } else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("standard_html_strip_deprecation", - "Deprecated analyzer [standard_html_strip] used, " + - "replace it with a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter"); - } - } - - @Override - public StandardHtmlStripAnalyzer get() { - return this.analyzer; - } -} diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java index e64bb96bfcfd4..6285d25e01f17 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java @@ -24,7 +24,6 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.WordDelimiterGraphFilter; import org.apache.lucene.analysis.miscellaneous.WordDelimiterIterator; -import org.elasticsearch.Version; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -106,14 +105,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } - else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - return this; - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } private int getFlag(int flag, Settings settings, String key, boolean defaultValue) { diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java index 85f94a86c6cbf..f33687ee22439 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java @@ -24,7 +24,6 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.WordDelimiterFilter; import org.apache.lucene.analysis.miscellaneous.WordDelimiterIterator; -import org.elasticsearch.Version; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -112,14 +111,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } - else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - return this; - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } public int getFlag(int flag, Settings settings, String key, boolean defaultValue) { diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java index f128c07361c45..977cf928304b9 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java @@ -19,14 +19,11 @@ package org.elasticsearch.analysis.common; -import org.apache.lucene.analysis.Analyzer; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.analysis.IndexAnalyzers; -import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; import org.elasticsearch.test.VersionUtils; @@ -53,27 +50,4 @@ public void testStandardHtmlStripAnalyzerDeprecationError() throws IOException { assertEquals("[standard_html_strip] analyzer is not supported for new indices, " + "use a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter", ex.getMessage()); } - - /** - * Check that the deprecated analyzer name "standard_html_strip" issues a deprecation warning for indices created since 6.5.0 until 7 - */ - public void testStandardHtmlStripAnalyzerDeprecationWarning() throws IOException { - Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .put(IndexMetaData.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, - VersionUtils.getPreviousVersion(Version.V_7_0_0))) - .put("index.analysis.analyzer.custom_analyzer.type", "standard_html_strip") - .putList("index.analysis.analyzer.custom_analyzer.stopwords", "a", "b") - .build(); - - IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); - try (CommonAnalysisPlugin commonAnalysisPlugin = new CommonAnalysisPlugin()) { - IndexAnalyzers analyzers = createTestAnalysis(idxSettings, settings, commonAnalysisPlugin).indexAnalyzers; - Analyzer analyzer = analyzers.get("custom_analyzer"); - assertNotNull(((NamedAnalyzer) analyzer).analyzer()); - assertWarnings( - "Deprecated analyzer [standard_html_strip] used, " + - "replace it with a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter"); - } - } } diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java index 6582188f33c0b..b412d03e0a740 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java @@ -42,11 +42,9 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import static org.hamcrest.Matchers.equalTo; @@ -279,27 +277,6 @@ public void testPreconfiguredTokenFilters() throws IOException { tf.get(idxSettings, null, tf.getName(), settings).getSynonymFilter(); } } - - Settings settings2 = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) - .put("path.home", createTempDir().toString()) - .putList("common_words", "a", "b") - .put("output_unigrams", "true") - .build(); - IndexSettings idxSettings2 = IndexSettingsModule.newIndexSettings("index", settings2); - - List expectedWarnings = new ArrayList<>(); - for (PreConfiguredTokenFilter tf : plugin.getPreConfiguredTokenFilters()) { - if (disallowedFilters.contains(tf.getName())) { - tf.get(idxSettings2, null, tf.getName(), settings2).getSynonymFilter(); - expectedWarnings.add("Token filter [" + tf.getName() + "] will not be usable to parse synonyms after v7.0"); - } - else { - tf.get(idxSettings2, null, tf.getName(), settings2).getSynonymFilter(); - } - } - assertWarnings(expectedWarnings.toArray(new String[0])); } public void testDisallowedTokenFilters() throws IOException { @@ -333,28 +310,6 @@ public void testDisallowedTokenFilters() throws IOException { e.getMessage()); } - settings = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) - .put("path.home", createTempDir().toString()) - .putList("common_words", "a", "b") - .put("output_unigrams", "true") - .build(); - idxSettings = IndexSettingsModule.newIndexSettings("index", settings); - - List expectedWarnings = new ArrayList<>(); - for (String factory : disallowedFactories) { - TokenFilterFactory tff = plugin.getTokenFilters().get(factory).get(idxSettings, null, factory, settings); - TokenizerFactory tok = new KeywordTokenizerFactory(idxSettings, null, "keyword", settings); - SynonymTokenFilterFactory stff = new SynonymTokenFilterFactory(idxSettings, null, "synonym", settings); - - stff.buildSynonymAnalyzer(tok, Collections.emptyList(), Collections.singletonList(tff), null); - expectedWarnings.add("Token filter [" + factory - + "] will not be usable to parse synonyms after v7.0"); - } - - assertWarnings(expectedWarnings.toArray(new String[0])); - settings = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java index 66746854c61f4..31484c8ade76e 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java @@ -22,10 +22,8 @@ import com.ibm.icu.text.FilteredNormalizer2; import com.ibm.icu.text.Normalizer2; import com.ibm.icu.text.UnicodeSet; - import org.apache.logging.log4j.LogManager; import org.apache.lucene.analysis.TokenStream; -import org.elasticsearch.Version; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -59,14 +57,7 @@ public TokenStream create(TokenStream tokenStream) { static Normalizer2 wrapWithUnicodeSetFilter(final IndexSettings indexSettings, final Normalizer2 normalizer, final Settings settings) { - String unicodeSetFilter = settings.get("unicodeSetFilter"); - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - if (unicodeSetFilter != null) { - deprecationLogger.deprecated("[unicodeSetFilter] has been deprecated in favor of [unicode_set_filter]"); - } else { - unicodeSetFilter = settings.get("unicode_set_filter"); - } - } + String unicodeSetFilter = settings.get("unicode_set_filter"); if (unicodeSetFilter != null) { UnicodeSet unicodeSet = new UnicodeSet(unicodeSetFilter); diff --git a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java index 1022b826475be..ca0f315e7a4b8 100644 --- a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java +++ b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java @@ -36,7 +36,6 @@ import org.apache.lucene.analysis.phonetic.DaitchMokotoffSoundexFilter; import org.apache.lucene.analysis.phonetic.DoubleMetaphoneFilter; import org.apache.lucene.analysis.phonetic.PhoneticFilter; -import org.elasticsearch.Version; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -148,13 +147,6 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } - else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - return this; - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } } diff --git a/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/AnalysisPhoneticFactoryTests.java b/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/AnalysisPhoneticFactoryTests.java index 2092d63fd23fc..da117d018b84d 100644 --- a/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/AnalysisPhoneticFactoryTests.java +++ b/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/AnalysisPhoneticFactoryTests.java @@ -60,18 +60,6 @@ public void testDisallowedWithSynonyms() throws IOException { = plugin.getTokenFilters().get("phonetic").get(idxSettings, null, "phonetic", settings); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, tff::getSynonymFilter); assertEquals("Token filter [phonetic] cannot be used to parse synonyms", e.getMessage()); - - settings = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), - Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) - .put("path.home", createTempDir().toString()) - .build(); - idxSettings = IndexSettingsModule.newIndexSettings("index", settings); - - tff = plugin.getTokenFilters().get("phonetic").get(idxSettings, null, "phonetic", settings); - tff.getSynonymFilter(); - - assertWarnings("Token filter [phonetic] will not be usable to parse synonyms after v7.0"); } } diff --git a/server/src/main/java/org/elasticsearch/index/analysis/PreConfiguredTokenFilter.java b/server/src/main/java/org/elasticsearch/index/analysis/PreConfiguredTokenFilter.java index 5776edd69fc83..5325821d050cb 100644 --- a/server/src/main/java/org/elasticsearch/index/analysis/PreConfiguredTokenFilter.java +++ b/server/src/main/java/org/elasticsearch/index/analysis/PreConfiguredTokenFilter.java @@ -137,14 +137,7 @@ public TokenFilterFactory getSynonymFilter() { if (allowForSynonymParsing) { return this; } - if (version.onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } - else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog(name(), "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - return this; - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } }; } @@ -164,14 +157,7 @@ public TokenFilterFactory getSynonymFilter() { if (allowForSynonymParsing) { return this; } - if (version.onOrAfter(Version.V_7_0_0)) { - throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); - } - else { - DEPRECATION_LOGGER.deprecatedAndMaybeLog(name(), "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); - return this; - } + throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } }; } From 29997721aa2e31f2259f9022e80e848c6f39fbf6 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 26 Apr 2019 08:46:10 -0700 Subject: [PATCH 2/4] fix test --- .../test/analysis_icu/10_basic.yml | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/plugins/analysis-icu/src/test/resources/rest-api-spec/test/analysis_icu/10_basic.yml b/plugins/analysis-icu/src/test/resources/rest-api-spec/test/analysis_icu/10_basic.yml index da95501c05d21..a4642078941ac 100644 --- a/plugins/analysis-icu/src/test/resources/rest-api-spec/test/analysis_icu/10_basic.yml +++ b/plugins/analysis-icu/src/test/resources/rest-api-spec/test/analysis_icu/10_basic.yml @@ -103,45 +103,3 @@ - match: { tokens.1.token: foo } - match: { tokens.2.token: bâr } - match: { tokens.3.token: russ } - ---- -"Normalization with deprecated unicodeSetFilter": - - skip: - reason: unicodeSetFilter deprecated in 7.0.0, replaced by unicode_set_filter - features: "warnings" - - - do: - warnings: - - "[unicodeSetFilter] has been deprecated in favor of [unicode_set_filter]" - indices.create: - index: test - body: - settings: - index: - analysis: - char_filter: - charfilter_icu_normalizer: - type: icu_normalizer - unicodeSetFilter: "[^ß]" - filter: - tokenfilter_icu_normalizer: - type: icu_normalizer - unicodeSetFilter: "[^ßB]" - tokenfilter_icu_folding: - type: icu_folding - unicodeSetFilter: "[^â]" - - do: - warnings: - - "[unicodeSetFilter] has been deprecated in favor of [unicode_set_filter]" - indices.analyze: - index: test - body: - char_filter: ["charfilter_icu_normalizer"] - tokenizer: standard - text: charfilter Föo Bâr Ruß - - length: { tokens: 4 } - - match: { tokens.0.token: charfilter } - - match: { tokens.1.token: föo } - - match: { tokens.2.token: bâr } - - match: { tokens.3.token: ruß } - From 56682a476f905fb1fd31293d06b2a03da1344b0e Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 26 Apr 2019 11:19:57 -0700 Subject: [PATCH 3/4] remove outdated tests --- .../common/CommonAnalysisPluginTests.java | 53 -------------- .../HtmlStripCharFilterFactoryTests.java | 73 ------------------- .../common/SynonymsAnalysisTests.java | 18 ----- 3 files changed, 144 deletions(-) delete mode 100644 modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java delete mode 100644 modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/HtmlStripCharFilterFactoryTests.java diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java deleted file mode 100644 index 977cf928304b9..0000000000000 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.analysis.common; - -import org.elasticsearch.Version; -import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.env.Environment; -import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.IndexSettingsModule; -import org.elasticsearch.test.VersionUtils; - -import java.io.IOException; - -public class CommonAnalysisPluginTests extends ESTestCase { - - /** - * Check that the deprecated analyzer name "standard_html_strip" throws exception for indices created since 7.0.0 - */ - public void testStandardHtmlStripAnalyzerDeprecationError() throws IOException { - Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .put(IndexMetaData.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT)) - .put("index.analysis.analyzer.custom_analyzer.type", "standard_html_strip") - .putList("index.analysis.analyzer.custom_analyzer.stopwords", "a", "b") - .build(); - - IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); - CommonAnalysisPlugin commonAnalysisPlugin = new CommonAnalysisPlugin(); - IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, - () -> createTestAnalysis(idxSettings, settings, commonAnalysisPlugin)); - assertEquals("[standard_html_strip] analyzer is not supported for new indices, " + - "use a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter", ex.getMessage()); - } -} diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/HtmlStripCharFilterFactoryTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/HtmlStripCharFilterFactoryTests.java deleted file mode 100644 index e284877978851..0000000000000 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/HtmlStripCharFilterFactoryTests.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.analysis.common; - -import org.elasticsearch.Version; -import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.env.Environment; -import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.analysis.CharFilterFactory; -import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.IndexSettingsModule; -import org.elasticsearch.test.VersionUtils; - -import java.io.IOException; -import java.io.StringReader; -import java.util.Map; - - -public class HtmlStripCharFilterFactoryTests extends ESTestCase { - - /** - * Check that the deprecated name "htmlStrip" issues a deprecation warning for indices created since 6.3.0 - */ - public void testDeprecationWarning() throws IOException { - Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_6_3_0, Version.CURRENT)) - .build(); - - IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); - try (CommonAnalysisPlugin commonAnalysisPlugin = new CommonAnalysisPlugin()) { - Map charFilters = createTestAnalysis(idxSettings, settings, commonAnalysisPlugin).charFilter; - CharFilterFactory charFilterFactory = charFilters.get("htmlStrip"); - assertNotNull(charFilterFactory.create(new StringReader("input"))); - assertWarnings("The [htmpStrip] char filter name is deprecated and will be removed in a future version. " - + "Please change the filter name to [html_strip] instead."); - } - } - - /** - * Check that the deprecated name "htmlStrip" does NOT issues a deprecation warning for indices created before 6.3.0 - */ - public void testNoDeprecationWarningPre6_3() throws IOException { - Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .put(IndexMetaData.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.V_6_2_4)) - .build(); - - IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); - try (CommonAnalysisPlugin commonAnalysisPlugin = new CommonAnalysisPlugin()) { - Map charFilters = createTestAnalysis(idxSettings, settings, commonAnalysisPlugin).charFilter; - CharFilterFactory charFilterFactory = charFilters.get("htmlStrip"); - assertNotNull(charFilterFactory.create(new StringReader(""))); - } - } -} diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java index b412d03e0a740..47fb4afae2ca8 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java @@ -309,24 +309,6 @@ public void testDisallowedTokenFilters() throws IOException { + "] cannot be used to parse synonyms", e.getMessage()); } - - settings = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) - .put("path.home", createTempDir().toString()) - .put("preserve_original", "false") - .build(); - idxSettings = IndexSettingsModule.newIndexSettings("index", settings); - TokenFilterFactory tff = plugin.getTokenFilters().get("multiplexer").get(idxSettings, null, "multiplexer", settings); - TokenizerFactory tok = new KeywordTokenizerFactory(idxSettings, null, "keyword", settings); - SynonymTokenFilterFactory stff = new SynonymTokenFilterFactory(idxSettings, null, "synonym", settings); - - IllegalArgumentException e = expectThrows(IllegalArgumentException.class, - () -> stff.buildSynonymAnalyzer(tok, Collections.emptyList(), Collections.singletonList(tff), null)); - - assertEquals("Token filter [multiplexer] cannot be used to parse synonyms unless [preserve_original] is [true]", - e.getMessage()); - } private void match(String analyzerName, String source, String target) throws IOException { From fcfc853cfa0e8784fe4fabb67399a395cb95bc5a Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 26 Apr 2019 15:26:38 -0700 Subject: [PATCH 4/4] fix rest tests --- .../test/analysis-common/40_token_filters.yml | 24 --------- .../test/indices.analyze/10_analyze.yml | 50 ------------------- 2 files changed, 74 deletions(-) diff --git a/modules/analysis-common/src/test/resources/rest-api-spec/test/analysis-common/40_token_filters.yml b/modules/analysis-common/src/test/resources/rest-api-spec/test/analysis-common/40_token_filters.yml index 3ce4b6bc04ed3..3486b9defd9d2 100644 --- a/modules/analysis-common/src/test/resources/rest-api-spec/test/analysis-common/40_token_filters.yml +++ b/modules/analysis-common/src/test/resources/rest-api-spec/test/analysis-common/40_token_filters.yml @@ -1135,30 +1135,6 @@ - match: { tokens.9.token: 落ち } - match: { tokens.10.token: ちた } ---- -"delimited_payload_filter_error": - - do: - catch: /\[delimited_payload_filter\] is not supported for new indices, use \[delimited_payload\] instead/ - indices.create: - index: test - body: - settings: - analysis: - filter: - my_delimited_payload_filter: - type: delimited_payload_filter - delimiter: ^ - encoding: identity - - # Test pre-configured token filter too: - - do: - catch: /\[delimited_payload_filter\] is not supported for new indices, use \[delimited_payload\] instead/ - indices.analyze: - body: - text: foo|5 - tokenizer: keyword - filter: [delimited_payload_filter] - --- "delimited_payload": - do: diff --git a/modules/analysis-common/src/test/resources/rest-api-spec/test/indices.analyze/10_analyze.yml b/modules/analysis-common/src/test/resources/rest-api-spec/test/indices.analyze/10_analyze.yml index baa32662b577f..7017b0c5a0859 100644 --- a/modules/analysis-common/src/test/resources/rest-api-spec/test/indices.analyze/10_analyze.yml +++ b/modules/analysis-common/src/test/resources/rest-api-spec/test/indices.analyze/10_analyze.yml @@ -14,56 +14,6 @@ - match: { error.type: illegal_argument_exception } - match: { error.reason: "Custom normalizer may not use filter [word_delimiter]" } ---- -"htmlStrip_deprecated": - - skip: - reason: deprecated - features: "warnings" - - - do: - indices.create: - index: test_deprecated_htmlstrip - body: - settings: - index: - analysis: - analyzer: - my_htmlStripWithCharfilter: - tokenizer: keyword - char_filter: ["htmlStrip"] - mappings: - properties: - name: - type: text - analyzer: my_htmlStripWithCharfilter - - - do: - warnings: - - 'The [htmpStrip] char filter name is deprecated and will be removed in a future version. Please change the filter name to [html_strip] instead.' - index: - index: test_deprecated_htmlstrip - id: 1 - body: { "name": "foo bar" } - - - do: - warnings: - - 'The [htmpStrip] char filter name is deprecated and will be removed in a future version. Please change the filter name to [html_strip] instead.' - index: - index: test_deprecated_htmlstrip - id: 2 - body: { "name": "foo baz" } - - - do: - warnings: - - 'The [htmpStrip] char filter name is deprecated and will be removed in a future version. Please change the filter name to [html_strip] instead.' - indices.analyze: - index: test_deprecated_htmlstrip - body: - analyzer: "my_htmlStripWithCharfilter" - text: "foo" - - length: { tokens: 1 } - - match: { tokens.0.token: "\nfoo\n" } - --- "Synonym filter with tokenizer": - do: