Skip to content

Commit 1c5b89c

Browse files
authored
Introduce deprecation categories (#68061)
Sort-of backport of #67443. Closes #64824. Introduce the concept of categories to deprecation logging. Every location where we log a deprecation message must now include a deprecation category.
1 parent 6c8ed22 commit 1c5b89c

File tree

172 files changed

+610
-311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+610
-311
lines changed

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.lucene.analysis.cjk.CJKBigramFilter;
2424
import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute;
2525
import org.elasticsearch.Version;
26+
import org.elasticsearch.common.logging.DeprecationCategory;
2627
import org.elasticsearch.common.logging.DeprecationLogger;
2728
import org.elasticsearch.common.settings.Settings;
2829
import org.elasticsearch.env.Environment;
@@ -102,7 +103,7 @@ public TokenFilterFactory getSynonymFilter() {
102103
"] cannot be used to parse synonyms");
103104
}
104105
else {
105-
DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name()
106+
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name()
106107
+ "] will not be usable to parse synonyms after v7.0");
107108
}
108109
}

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
117117
import org.elasticsearch.cluster.service.ClusterService;
118118
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
119+
import org.elasticsearch.common.logging.DeprecationCategory;
119120
import org.elasticsearch.common.logging.DeprecationLogger;
120121
import org.elasticsearch.common.regex.Regex;
121122
import org.elasticsearch.common.settings.Settings;
@@ -249,7 +250,7 @@ public Map<String, AnalysisProvider<TokenFilterFactory>> getTokenFilters() {
249250
filters.put("dutch_stem", DutchStemTokenFilterFactory::new);
250251
filters.put("edge_ngram", EdgeNGramTokenFilterFactory::new);
251252
filters.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
252-
deprecationLogger.deprecate("edgeNGram_deprecation",
253+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation",
253254
"The [edgeNGram] token filter name is deprecated and will be removed in a future version. "
254255
+ "Please change the filter name to [edge_ngram] instead.");
255256
return new EdgeNGramTokenFilterFactory(indexSettings, environment, name, settings);
@@ -274,7 +275,7 @@ public Map<String, AnalysisProvider<TokenFilterFactory>> getTokenFilters() {
274275
filters.put("multiplexer", MultiplexerTokenFilterFactory::new);
275276
filters.put("ngram", NGramTokenFilterFactory::new);
276277
filters.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
277-
deprecationLogger.deprecate("nGram_deprecation",
278+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_deprecation",
278279
"The [nGram] token filter name is deprecated and will be removed in a future version. "
279280
+ "Please change the filter name to [ngram] instead.");
280281
return new NGramTokenFilterFactory(indexSettings, environment, name, settings);
@@ -323,7 +324,7 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
323324
tokenizers.put("thai", ThaiTokenizerFactory::new);
324325
tokenizers.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
325326
if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
326-
deprecationLogger.deprecate("nGram_tokenizer_deprecation",
327+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation",
327328
"The [nGram] tokenizer name is deprecated and will be removed in a future version. "
328329
+ "Please change the tokenizer name to [ngram] instead.");
329330
}
@@ -332,7 +333,7 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
332333
tokenizers.put("ngram", NGramTokenizerFactory::new);
333334
tokenizers.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
334335
if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
335-
deprecationLogger.deprecate("edgeNGram_tokenizer_deprecation",
336+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation",
336337
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
337338
+ "Please change the tokenizer name to [edge_ngram] instead.");
338339
}
@@ -413,7 +414,7 @@ public List<PreConfiguredCharFilter> getPreConfiguredCharFilters() {
413414
filters.add(PreConfiguredCharFilter.singleton("html_strip", false, HTMLStripCharFilter::new));
414415
filters.add(PreConfiguredCharFilter.elasticsearchVersion("htmlStrip", false, (reader, version) -> {
415416
if (version.onOrAfter(org.elasticsearch.Version.V_6_3_0)) {
416-
deprecationLogger.deprecate("htmlStrip_deprecation",
417+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "htmlStrip_deprecation",
417418
"The [htmpStrip] char filter name is deprecated and will be removed in a future version. "
418419
+ "Please change the filter name to [html_strip] instead.");
419420
}
@@ -444,7 +445,7 @@ public List<PreConfiguredTokenFilter> getPreConfiguredTokenFilters() {
444445
"[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead");
445446
}
446447
if (version.onOrAfter(Version.V_6_2_0)) {
447-
deprecationLogger.deprecate("analysis_delimited_payload_filter",
448+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "analysis_delimited_payload_filter",
448449
"Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]");
449450
}
450451
return new DelimitedPayloadTokenFilter(input,
@@ -464,7 +465,7 @@ public List<PreConfiguredTokenFilter> getPreConfiguredTokenFilters() {
464465
"The [edgeNGram] token filter name was deprecated in 6.4 and cannot be used in new indices. "
465466
+ "Please change the filter name to [edge_ngram] instead.");
466467
} else {
467-
deprecationLogger.deprecate("edgeNGram_deprecation",
468+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation",
468469
"The [edgeNGram] token filter name is deprecated and will be removed in a future version. "
469470
+ "Please change the filter name to [edge_ngram] instead.");
470471
}
@@ -491,7 +492,7 @@ public List<PreConfiguredTokenFilter> getPreConfiguredTokenFilters() {
491492
throw new IllegalArgumentException("The [nGram] token filter name was deprecated in 6.4 and cannot be used in new indices. "
492493
+ "Please change the filter name to [ngram] instead.");
493494
} else {
494-
deprecationLogger.deprecate("nGram_deprecation",
495+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_deprecation",
495496
"The [nGram] token filter name is deprecated and will be removed in a future version. "
496497
+ "Please change the filter name to [ngram] instead.");
497498
}
@@ -569,15 +570,15 @@ public List<PreConfiguredTokenizer> getPreConfiguredTokenizers() {
569570
// Temporary shim for aliases. TODO deprecate after they are moved
570571
tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("nGram", (version) -> {
571572
if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
572-
deprecationLogger.deprecate("nGram_tokenizer_deprecation",
573+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation",
573574
"The [nGram] tokenizer name is deprecated and will be removed in a future version. "
574575
+ "Please change the tokenizer name to [ngram] instead.");
575576
}
576577
return new NGramTokenizer();
577578
}));
578579
tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("edgeNGram", (version) -> {
579580
if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
580-
deprecationLogger.deprecate("edgeNGram_tokenizer_deprecation",
581+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation",
581582
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
582583
+ "Please change the tokenizer name to [edge_ngram] instead.");
583584
}

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonGramsTokenFilterFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.lucene.analysis.commongrams.CommonGramsFilter;
2525
import org.apache.lucene.analysis.commongrams.CommonGramsQueryFilter;
2626
import org.elasticsearch.Version;
27+
import org.elasticsearch.common.logging.DeprecationCategory;
2728
import org.elasticsearch.common.logging.DeprecationLogger;
2829
import org.elasticsearch.common.settings.Settings;
2930
import org.elasticsearch.env.Environment;
@@ -69,7 +70,7 @@ public TokenFilterFactory getSynonymFilter() {
6970
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) {
7071
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
7172
} else {
72-
DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name()
73+
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name()
7374
+ "] will not be usable to parse synonyms after v7.0");
7475
}
7576

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/EdgeNGramTokenFilterFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter;
2424
import org.apache.lucene.analysis.reverse.ReverseStringFilter;
2525
import org.elasticsearch.Version;
26+
import org.elasticsearch.common.logging.DeprecationCategory;
2627
import org.elasticsearch.common.logging.DeprecationLogger;
2728
import org.elasticsearch.common.settings.Settings;
2829
import org.elasticsearch.env.Environment;
@@ -91,8 +92,8 @@ public TokenFilterFactory getSynonymFilter() {
9192
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
9293
}
9394
else {
94-
DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name()
95-
+ "] will not be usable to parse synonyms after v7.0");
95+
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
96+
"Token filter [" + name() + "] will not be usable to parse synonyms after v7.0");
9697
return this;
9798
}
9899
}

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/FingerprintTokenFilterFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.lucene.analysis.TokenStream;
2323
import org.apache.lucene.analysis.miscellaneous.FingerprintFilter;
2424
import org.elasticsearch.Version;
25+
import org.elasticsearch.common.logging.DeprecationCategory;
2526
import org.elasticsearch.common.logging.DeprecationLogger;
2627
import org.elasticsearch.common.settings.Settings;
2728
import org.elasticsearch.env.Environment;
@@ -58,7 +59,7 @@ public TokenFilterFactory getSynonymFilter() {
5859
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
5960
}
6061
else {
61-
DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name()
62+
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name()
6263
+ "] will not be usable to parse synonyms after v7.0");
6364
return this;
6465
}

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.analysis.common;
2121

2222
import org.elasticsearch.Version;
23+
import org.elasticsearch.common.logging.DeprecationCategory;
2324
import org.elasticsearch.common.logging.DeprecationLogger;
2425
import org.elasticsearch.common.settings.Settings;
2526
import org.elasticsearch.env.Environment;
@@ -37,7 +38,7 @@ public class LegacyDelimitedPayloadTokenFilterFactory extends DelimitedPayloadTo
3738
"[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead");
3839
}
3940
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_2_0)) {
40-
deprecationLogger.deprecate("analysis_legacy_delimited_payload_filter",
41+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "analysis_legacy_delimited_payload_filter",
4142
"Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]");
4243
}
4344
}

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
2727
import org.elasticsearch.Version;
2828
import org.elasticsearch.common.Strings;
29+
import org.elasticsearch.common.logging.DeprecationCategory;
2930
import org.elasticsearch.common.logging.DeprecationLogger;
3031
import org.elasticsearch.common.settings.Settings;
3132
import org.elasticsearch.env.Environment;
@@ -66,8 +67,8 @@ public TokenFilterFactory getSynonymFilter() {
6667
}
6768
else {
6869
if (preserveOriginal) {
69-
DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name()
70-
+ "] will not be usable to parse synonyms after v7.0");
70+
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
71+
"Token filter [" + name() + "] will not be usable to parse synonyms after v7.0");
7172
return IDENTITY_FILTER;
7273
}
7374
throw new IllegalArgumentException("Token filter [" + name()
@@ -129,8 +130,8 @@ public TokenFilterFactory getSynonymFilter() {
129130
}
130131
else {
131132
if (preserveOriginal) {
132-
DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name()
133-
+ "] will not be usable to parse synonyms after v7.0");
133+
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
134+
"Token filter [" + name() + "] will not be usable to parse synonyms after v7.0");
134135
return IDENTITY_FILTER;
135136
}
136137
throw new IllegalArgumentException("Token filter [" + name()

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.lucene.analysis.TokenStream;
2323
import org.apache.lucene.analysis.ngram.NGramTokenFilter;
2424
import org.elasticsearch.Version;
25+
import org.elasticsearch.common.logging.DeprecationCategory;
2526
import org.elasticsearch.common.logging.DeprecationLogger;
2627
import org.elasticsearch.common.settings.Settings;
2728
import org.elasticsearch.env.Environment;
@@ -52,7 +53,7 @@ public class NGramTokenFilterFactory extends AbstractTokenFilterFactory {
5253
+ maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the ["
5354
+ IndexSettings.MAX_NGRAM_DIFF_SETTING.getKey() + "] index level setting.");
5455
} else {
55-
deprecationLogger.deprecate("ngram_big_difference",
56+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "ngram_big_difference",
5657
"Deprecated big difference between max_gram and min_gram in NGram Tokenizer,"
5758
+ "expected difference must be less than or equal to: [" + maxAllowedNgramDiff + "]");
5859
}
@@ -71,8 +72,8 @@ public TokenFilterFactory getSynonymFilter() {
7172
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
7273
}
7374
else {
74-
DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name()
75-
+ "] will not be usable to parse synonyms after v7.0");
75+
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
76+
"Token filter [" + name() + "] will not be usable to parse synonyms after v7.0");
7677
return this;
7778
}
7879
}

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.lucene.analysis.Tokenizer;
2323
import org.apache.lucene.analysis.ngram.NGramTokenizer;
2424
import org.elasticsearch.Version;
25+
import org.elasticsearch.common.logging.DeprecationCategory;
2526
import org.elasticsearch.common.settings.Settings;
2627
import org.elasticsearch.env.Environment;
2728
import org.elasticsearch.index.IndexSettings;
@@ -118,7 +119,7 @@ public boolean isTokenChar(int c) {
118119
+ maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the ["
119120
+ IndexSettings.MAX_NGRAM_DIFF_SETTING.getKey() + "] index level setting.");
120121
} else {
121-
deprecationLogger.deprecate("ngram_big_difference",
122+
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "ngram_big_difference",
122123
"Deprecated big difference between max_gram and min_gram in NGram Tokenizer,"
123124
+ "expected difference must be less than or equal to: [" + maxAllowedNgramDiff + "]");
124125
}

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StandardHtmlStripAnalyzerProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.lucene.analysis.CharArraySet;
2323
import org.elasticsearch.Version;
24+
import org.elasticsearch.common.logging.DeprecationCategory;
2425
import org.elasticsearch.common.logging.DeprecationLogger;
2526
import org.elasticsearch.common.settings.Settings;
2627
import org.elasticsearch.env.Environment;
@@ -49,7 +50,7 @@ public class StandardHtmlStripAnalyzerProvider extends AbstractIndexAnalyzerProv
4950
throw new IllegalArgumentException("[standard_html_strip] analyzer is not supported for new indices, " +
5051
"use a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter");
5152
} else {
52-
DEPRECATION_LOGGER.deprecate("standard_html_strip_deprecation",
53+
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "standard_html_strip_deprecation",
5354
"Deprecated analyzer [standard_html_strip] used, " +
5455
"replace it with a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter");
5556
}

0 commit comments

Comments
 (0)