Skip to content

Commit d7cc38f

Browse files
committed
Issue deprecation warnings when preconfigured delimited_payload_filter is used (#43684)
that warnings would be emitted when both a normal and pre-configured filter were used. Unfortunately, due to a bug in the Analyze API, the pre- configured filter check was never actually triggered, and it turns out that the deprecation warning was not in fact being emitted in this case. This commit ensures that the preconfigured filter also emits the warnings and triggers an error if a new index tries to use a preconfigured delimited_payload_filter
1 parent a97e483 commit d7cc38f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

+12-4
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,18 @@ public List<PreConfiguredTokenFilter> getPreConfiguredTokenFilters() {
403403
input -> new CommonGramsFilter(input, CharArraySet.EMPTY_SET)));
404404
filters.add(PreConfiguredTokenFilter.singleton("czech_stem", false, CzechStemFilter::new));
405405
filters.add(PreConfiguredTokenFilter.singleton("decimal_digit", true, DecimalDigitFilter::new));
406-
filters.add(PreConfiguredTokenFilter.singleton("delimited_payload_filter", false, input ->
407-
new DelimitedPayloadTokenFilter(input,
408-
DelimitedPayloadTokenFilterFactory.DEFAULT_DELIMITER,
409-
DelimitedPayloadTokenFilterFactory.DEFAULT_ENCODER)));
406+
filters.add(PreConfiguredTokenFilter.singletonWithVersion("delimited_payload_filter", false, (input, version) -> {
407+
if (version.onOrAfter(org.elasticsearch.Version.V_7_0_0)) {
408+
throw new IllegalArgumentException(
409+
"[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead");
410+
}
411+
if (version.onOrAfter(org.elasticsearch.Version.V_6_2_0)) {
412+
deprecationLogger.deprecated("Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]");
413+
}
414+
return new DelimitedPayloadTokenFilter(input,
415+
DelimitedPayloadTokenFilterFactory.DEFAULT_DELIMITER,
416+
DelimitedPayloadTokenFilterFactory.DEFAULT_ENCODER);
417+
}));
410418
filters.add(PreConfiguredTokenFilter.singleton("delimited_payload", false, input ->
411419
new DelimitedPayloadTokenFilter(input,
412420
DelimitedPayloadTokenFilterFactory.DEFAULT_DELIMITER,

0 commit comments

Comments
 (0)