Skip to content

Commit 51bdace

Browse files
committed
[Analysis] Deprecate Standard Html Strip Analyzer
Change version to 7_0_0 and fix deprecationlogger error Related #4704
1 parent cbe7243 commit 51bdace

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
package org.elasticsearch.analysis.common;
2121

22+
import org.apache.logging.log4j.LogManager;
2223
import org.apache.lucene.analysis.CharArraySet;
2324
import org.elasticsearch.Version;
2425
import org.elasticsearch.common.logging.DeprecationLogger;
25-
import org.elasticsearch.common.logging.Loggers;
2626
import org.elasticsearch.common.settings.Settings;
2727
import org.elasticsearch.env.Environment;
2828
import org.elasticsearch.index.IndexSettings;
@@ -32,7 +32,7 @@
3232
public class StandardHtmlStripAnalyzerProvider extends AbstractIndexAnalyzerProvider<StandardHtmlStripAnalyzer> {
3333

3434
private static final DeprecationLogger DEPRECATION_LOGGER =
35-
new DeprecationLogger(Loggers.getLogger(StandardHtmlStripAnalyzerProvider.class));
35+
new DeprecationLogger(LogManager.getLogger(StandardHtmlStripAnalyzerProvider.class));
3636

3737
private final StandardHtmlStripAnalyzer analyzer;
3838

@@ -46,7 +46,7 @@ public class StandardHtmlStripAnalyzerProvider extends AbstractIndexAnalyzerProv
4646
CharArraySet stopWords = Analysis.parseStopWords(env, settings, defaultStopwords);
4747
analyzer = new StandardHtmlStripAnalyzer(stopWords);
4848
analyzer.setVersion(version);
49-
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0_alpha1)) {
49+
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) {
5050
throw new IllegalArgumentException("[standard_html_strip] analyzer is not supported for new indices, " +
5151
"use a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter");
5252
} else {

modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void testEdgeNGramNoDeprecationWarningPre6_4() throws IOException {
127127
public void testStandardHtmlStripAnalyzerDeprecationError() throws IOException {
128128
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
129129
.put(IndexMetaData.SETTING_VERSION_CREATED,
130-
VersionUtils.randomVersionBetween(random(), Version.V_7_0_0_alpha1, Version.CURRENT))
130+
VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT))
131131
.put("index.analysis.analyzer.custom_analyzer.type", "standard_html_strip")
132132
.putList("index.analysis.analyzer.custom_analyzer.stopwords", "a", "b")
133133
.build();
@@ -147,7 +147,7 @@ public void testStandardHtmlStripAnalyzerDeprecationWarning() throws IOException
147147
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
148148
.put(IndexMetaData.SETTING_VERSION_CREATED,
149149
VersionUtils.randomVersionBetween(random(), Version.V_6_0_0,
150-
VersionUtils.getPreviousVersion(Version.V_7_0_0_alpha1)))
150+
VersionUtils.getPreviousVersion(Version.V_7_0_0)))
151151
.put("index.analysis.analyzer.custom_analyzer.type", "standard_html_strip")
152152
.putList("index.analysis.analyzer.custom_analyzer.stopwords", "a", "b")
153153
.build();

server/src/main/java/org/elasticsearch/index/analysis/AnalysisRegistry.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import org.apache.lucene.analysis.Analyzer;
2222
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
2323
import org.elasticsearch.Version;
24-
import org.elasticsearch.common.logging.DeprecationLogger;
25-
import org.elasticsearch.common.logging.Loggers;
2624
import org.elasticsearch.core.internal.io.IOUtils;
2725
import org.elasticsearch.ElasticsearchException;
2826
import org.elasticsearch.cluster.metadata.IndexMetaData;
@@ -54,7 +52,6 @@ public final class AnalysisRegistry implements Closeable {
5452
public static final String INDEX_ANALYSIS_CHAR_FILTER = "index.analysis.char_filter";
5553
public static final String INDEX_ANALYSIS_FILTER = "index.analysis.filter";
5654
public static final String INDEX_ANALYSIS_TOKENIZER = "index.analysis.tokenizer";
57-
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(AnalysisRegistry.class));
5855
private final PrebuiltAnalysis prebuiltAnalysis;
5956
private final Map<String, Analyzer> cachedAnalyzer = new ConcurrentHashMap<>();
6057

@@ -135,7 +132,7 @@ public Analyzer getAnalyzer(String analyzer) throws IOException {
135132
}}
136133
);
137134
} else if ("standard_html_strip".equals(analyzer)) {
138-
if (Version.CURRENT.onOrAfter(Version.V_7_0_0_alpha1)) {
135+
if (Version.CURRENT.onOrAfter(Version.V_7_0_0)) {
139136
throw new IllegalArgumentException("[standard_html_strip] analyzer is not supported for new indices, " +
140137
"use a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter");
141138
}

0 commit comments

Comments
 (0)