Skip to content

Commit 213518a

Browse files
authored
Deprecation check for percolator.map_unmapped_fields_as_string (#36460)
Adds a deprecation check for the removed setting `index.percolator.map_unmapped_fields_as_string`
1 parent fcf59ab commit 213518a

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ private DeprecationChecks() {
4949
Collections.unmodifiableList(Arrays.asList(
5050
IndexDeprecationChecks::oldIndicesCheck,
5151
IndexDeprecationChecks::delimitedPayloadFilterCheck,
52+
IndexDeprecationChecks::percolatorUnmappedFieldsAsStringCheck,
5253
IndexDeprecationChecks::indexNameCheck
5354
));
5455

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,17 @@ static DeprecationIssue indexNameCheck(IndexMetaData indexMetaData) {
116116
}
117117
return null;
118118
}
119+
120+
static DeprecationIssue percolatorUnmappedFieldsAsStringCheck(IndexMetaData indexMetaData) {
121+
if (indexMetaData.getSettings().hasValue("index.percolator.map_unmapped_fields_as_text")) {
122+
String settingValue = indexMetaData.getSettings().get("index.percolator.map_unmapped_fields_as_text");
123+
return new DeprecationIssue(DeprecationIssue.Level.WARNING,
124+
"Setting index.percolator.map_unmapped_fields_as_text has been renamed",
125+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
126+
"#_percolator",
127+
"The index setting [index.percolator.map_unmapped_fields_as_text] currently set to [" + settingValue +
128+
"] been removed in favor of [index.percolator.map_unmapped_fields_as_text].");
129+
}
130+
return null;
131+
}
119132
}

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
1515

1616
import java.util.List;
17+
import java.util.Locale;
1718

1819
import static java.util.Collections.singletonList;
1920
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.INDEX_SETTINGS_CHECKS;
@@ -76,4 +77,33 @@ public void testIndexNameCheck(){
7677
List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex));
7778
assertTrue(noIssues.isEmpty());
7879
}
80+
81+
public void testPercolatorUnmappedFieldsAsStringCheck() {
82+
boolean settingValue = randomBoolean();
83+
Settings settings = settings(
84+
VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.CURRENT)))
85+
.put("index.percolator.map_unmapped_fields_as_text", settingValue).build();
86+
final IndexMetaData badIndex = IndexMetaData.builder(randomAlphaOfLengthBetween(1,30).toLowerCase(Locale.ROOT))
87+
.settings(settings)
88+
.numberOfShards(randomIntBetween(1,100))
89+
.numberOfReplicas(randomIntBetween(1,15))
90+
.build();
91+
92+
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING,
93+
"Setting index.percolator.map_unmapped_fields_as_text has been renamed",
94+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
95+
"#_percolator",
96+
"The index setting [index.percolator.map_unmapped_fields_as_text] currently set to [" + settingValue +
97+
"] been removed in favor of [index.percolator.map_unmapped_fields_as_text].");
98+
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(badIndex));
99+
assertEquals(singletonList(expected), issues);
100+
101+
final IndexMetaData goodIndex = IndexMetaData.builder(randomAlphaOfLengthBetween(1,30).toLowerCase(Locale.ROOT))
102+
.settings(settings(Version.CURRENT))
103+
.numberOfShards(randomIntBetween(1,100))
104+
.numberOfReplicas(randomIntBetween(1,15))
105+
.build();
106+
List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex));
107+
assertTrue(noIssues.isEmpty());
108+
}
79109
}

0 commit comments

Comments
 (0)