Skip to content

Instantly share code, notes, and snippets.

@mayya-sharipova
Created January 17, 2018 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayya-sharipova/27cdcdc427327235d126c11280ee01ba to your computer and use it in GitHub Desktop.
Save mayya-sharipova/27cdcdc427327235d126c11280ee01ba to your computer and use it in GitHub Desktop.
@@ -42,6 +42,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import static java.util.Collections.unmodifiableMap;
+import org.elasticsearch.common.logging.DeprecationLogger;
+import org.elasticsearch.common.logging.Loggers;
/**
* An internal registry for tokenizer, token filter, char filter and analyzer.
@@ -61,6 +63,9 @@ public final class AnalysisRegistry implements Closeable {
private final Map<String, AnalysisProvider<AnalyzerProvider<?>>> analyzers;
private final Map<String, AnalysisProvider<AnalyzerProvider<?>>> normalizers;
+ private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(AnalysisRegistry.class));
+
+
public AnalysisRegistry(Environment environment,
Map<String, AnalysisProvider<CharFilterFactory>> charFilters,
Map<String, AnalysisProvider<TokenFilterFactory>> tokenFilters,
@@ -111,6 +116,11 @@ public final class AnalysisRegistry implements Closeable {
* Returns a registered {@link CharFilterFactory} provider by name or <code>null</code> if the char filter was not registered
*/
public AnalysisModule.AnalysisProvider<CharFilterFactory> getCharFilterProvider(String charFilter) {
+ if (charFilter.equals("htmlStrip")){
+ DEPRECATION_LOGGER.deprecated("The [htmpStrip] char filter name is deprecated and will be removed in a future version. "
+ + "Please change the filter name to [html_strip] instead.");
+ charFilter = "html_strip";
+ }
return charFilters.getOrDefault(charFilter, this.prebuiltAnalysis.getCharFilterFactory(charFilter));
}
@@ -332,6 +342,11 @@ public final class AnalysisRegistry implements Closeable {
continue;
}
}
+ if (component.name().equals("CHAR_FILTER") && typeName.equals("htmlStrip")){
+ DEPRECATION_LOGGER.deprecated("The [htmpStrip] char filter name is deprecated and will be removed in a future version. "
+ + "Please change the filter name to [html_strip] instead.");
+ typeName = "html_strip";
+ }
AnalysisProvider<T> type = getAnalysisProvider(component, providerMap, name, typeName);
if (type == null) {
throw new IllegalArgumentException("Unknown " + component + " type [" + typeName + "] for [" + name + "]");
60,1 Bot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment