Add migration check for deprecated `delimited_payload_filter` (elastic/x-pack-elasticsearch#4310)
Add a check to the migration assistant to warn about the renaming of `delimited_payload_filter` to `delimited_payload`. This should still word for old indices from 7.0 on but will throw an error for newly created indices and the user should be warned about it when running the migration checks. Original commit: elastic/x-pack-elasticsearch@5d55e4e499
This commit is contained in:
parent
d340cd5a00
commit
5a59c5394f
|
@ -37,7 +37,6 @@ public class DeprecationChecks {
|
|||
// STUB
|
||||
));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static List<Function<IndexMetaData, DeprecationIssue>> INDEX_SETTINGS_CHECKS =
|
||||
Collections.unmodifiableList(Arrays.asList(
|
||||
IndexDeprecationChecks::baseSimilarityDefinedCheck,
|
||||
|
@ -45,6 +44,7 @@ public class DeprecationChecks {
|
|||
IndexDeprecationChecks::dynamicTemplateWithMatchMappingTypeCheck,
|
||||
IndexDeprecationChecks::indexSharedFileSystemCheck,
|
||||
IndexDeprecationChecks::indexStoreTypeCheck,
|
||||
IndexDeprecationChecks::storeThrottleSettingsCheck));
|
||||
IndexDeprecationChecks::storeThrottleSettingsCheck,
|
||||
IndexDeprecationChecks::delimitedPayloadFilterCheck));
|
||||
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ package org.elasticsearch.xpack.deprecation;
|
|||
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.analysis.AnalysisRegistry;
|
||||
import org.elasticsearch.index.mapper.DynamicTemplate;
|
||||
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
|
||||
|
||||
|
@ -127,7 +129,6 @@ public class IndexDeprecationChecks {
|
|||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static DeprecationIssue baseSimilarityDefinedCheck(IndexMetaData indexMetaData) {
|
||||
if (indexMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) {
|
||||
Settings settings = indexMetaData.getSettings().getAsSettings("index.similarity.base");
|
||||
|
@ -143,7 +144,26 @@ public class IndexDeprecationChecks {
|
|||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static DeprecationIssue delimitedPayloadFilterCheck(IndexMetaData indexMetaData) {
|
||||
if (indexMetaData.getCreationVersion().before(Version.V_7_0_0_alpha1)) {
|
||||
List<String> issues = new ArrayList<>();
|
||||
Map<String, Settings> filters = indexMetaData.getSettings().getGroups(AnalysisRegistry.INDEX_ANALYSIS_FILTER);
|
||||
for (Map.Entry<String, Settings> entry : filters.entrySet()) {
|
||||
if ("delimited_payload_filter".equals(entry.getValue().get("type"))) {
|
||||
issues.add("The filter [" + entry.getKey() + "] is of deprecated 'delimited_payload_filter' type. "
|
||||
+ "The filter type should be changed to 'delimited_payload'.");
|
||||
}
|
||||
}
|
||||
if (issues.size() > 0) {
|
||||
return new DeprecationIssue(DeprecationIssue.Level.WARNING,
|
||||
"Use of 'delimited_payload_filter'.",
|
||||
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_70_analysis_changes.html",
|
||||
issues.toString());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static DeprecationIssue indexStoreTypeCheck(IndexMetaData indexMetaData) {
|
||||
if (indexMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1) &&
|
||||
indexMetaData.getSettings().get("index.store.type") != null) {
|
||||
|
@ -158,7 +178,6 @@ public class IndexDeprecationChecks {
|
|||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static DeprecationIssue storeThrottleSettingsCheck(IndexMetaData indexMetaData) {
|
||||
if (indexMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) {
|
||||
Settings settings = indexMetaData.getSettings();
|
||||
|
@ -181,7 +200,6 @@ public class IndexDeprecationChecks {
|
|||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static DeprecationIssue indexSharedFileSystemCheck(IndexMetaData indexMetaData) {
|
||||
if (indexMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1) &&
|
||||
indexMetaData.getSettings().get("index.shared_filesystem") != null) {
|
||||
|
|
|
@ -8,9 +8,11 @@ package org.elasticsearch.xpack.deprecation;
|
|||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.VersionUtils;
|
||||
import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
|
||||
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
|
||||
|
||||
|
@ -22,7 +24,7 @@ import static org.elasticsearch.xpack.deprecation.DeprecationChecks.INDEX_SETTIN
|
|||
|
||||
public class IndexDeprecationChecksTests extends ESTestCase {
|
||||
|
||||
private void assertSettingsAndIssue(String key, String value, DeprecationIssue expected) {
|
||||
private static void assertSettingsAndIssue(String key, String value, DeprecationIssue expected) {
|
||||
IndexMetaData indexMetaData = IndexMetaData.builder("test")
|
||||
.settings(settings(Version.V_5_6_0)
|
||||
.put(key, value))
|
||||
|
@ -164,4 +166,21 @@ public class IndexDeprecationChecksTests extends ESTestCase {
|
|||
"https://www.elastic.co/guide/en/elasticsearch/reference/6.0/" +
|
||||
"breaking_60_indices_changes.html#_shadow_replicas_have_been_removed", null));
|
||||
}
|
||||
|
||||
public void testDelimitedPayloadFilterCheck() throws IOException {
|
||||
Settings settings = settings(
|
||||
VersionUtils.randomVersionBetween(random(), Version.V_5_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0_alpha1)))
|
||||
.put("index.analysis.filter.my_delimited_payload_filter.type", "delimited_payload_filter")
|
||||
.put("index.analysis.filter.my_delimited_payload_filter.delimiter", "^")
|
||||
.put("index.analysis.filter.my_delimited_payload_filter.encoding", "identity").build();
|
||||
|
||||
IndexMetaData indexMetaData = IndexMetaData.builder("test").settings(settings).numberOfShards(1).numberOfReplicas(0).build();
|
||||
|
||||
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, "Use of 'delimited_payload_filter'.",
|
||||
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_70_analysis_changes.html",
|
||||
"[The filter [my_delimited_payload_filter] is of deprecated 'delimited_payload_filter' type. "
|
||||
+ "The filter type should be changed to 'delimited_payload'.]");
|
||||
List<DeprecationIssue> issues = DeprecationInfoAction.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(indexMetaData));
|
||||
assertEquals(singletonList(expected), issues);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue