Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed deprecation info details message for geo_shape #77384

Merged
merged 2 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
}

@SuppressWarnings("unchecked")
private static String getDetailsMessageForComponentTemplates(Map<String, ComponentTemplate> componentTemplates) {
private static String getDetailsMessageForGeoShapeComponentTemplates(Map<String, ComponentTemplate> componentTemplates) {
String detailsForComponentTemplates =
componentTemplates.entrySet().stream().map((templateCursor) -> {
String templateName = templateCursor.getKey();
Expand Down Expand Up @@ -238,7 +238,7 @@ private static String getDetailsMessageForComponentTemplates(Map<String, Compone
}

@SuppressWarnings("unchecked")
private static String getDetailsMessageForIndexTemplates(ImmutableOpenMap<String, IndexTemplateMetadata> indexTemplates) {
private static String getDetailsMessageForGeoShapeIndexTemplates(ImmutableOpenMap<String, IndexTemplateMetadata> indexTemplates) {
String detailsForIndexTemplates =
StreamSupport.stream(indexTemplates.spliterator(), false).map((templateCursor) -> {
String templateName = templateCursor.key;
Expand Down Expand Up @@ -268,8 +268,9 @@ private static String getDetailsMessageForIndexTemplates(ImmutableOpenMap<String

@SuppressWarnings("unchecked")
static DeprecationIssue checkGeoShapeTemplates(final ClusterState clusterState) {
String detailsForComponentTemplates = getDetailsMessageForComponentTemplates(clusterState.getMetadata().componentTemplates());
String detailsForIndexTemplates = getDetailsMessageForIndexTemplates(clusterState.getMetadata().getTemplates());
String detailsForComponentTemplates =
getDetailsMessageForGeoShapeComponentTemplates(clusterState.getMetadata().componentTemplates());
String detailsForIndexTemplates = getDetailsMessageForGeoShapeIndexTemplates(clusterState.getMetadata().getTemplates());
boolean deprecationInComponentTemplates = Strings.isEmpty(detailsForComponentTemplates) == false;
boolean deprecationInIndexTemplates = Strings.isEmpty(detailsForIndexTemplates) == false;
String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_mappings_changes";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ protected static String formatDeprecatedGeoShapeParamMessage(String type, Map.En
Map<?, ?> value = (Map<?, ?>) entry.getValue();
return LegacyGeoShapeFieldMapper.DEPRECATED_PARAMETERS.stream()
.filter(deprecatedParameter -> value.containsKey(deprecatedParameter))
.map(deprecatedParameter -> String.format(Locale.ROOT, "parameter [%s] in field [%s]", type, deprecatedParameter, fieldName))
.map(deprecatedParameter -> String.format(Locale.ROOT, "parameter [%s] in field [%s]", deprecatedParameter, fieldName))
.collect(Collectors.joining("; "));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ public void testCheckGeoShapeMappings() throws Exception {
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"index templates contain deprecated geo_shape properties that must be removed",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_mappings_changes",
"mappings in index template single-type contains deprecated geo_shape properties. [parameter [geo_shape] in field " +
"[points_only]; parameter [geo_shape] in field [strategy]]", false, null)
"mappings in index template single-type contains deprecated geo_shape properties. [parameter [points_only] in field " +
"[location]; parameter [strategy] in field [location]]", false, null)
));

// Second, testing only a component template:
Expand All @@ -417,8 +417,8 @@ public void testCheckGeoShapeMappings() throws Exception {
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"component templates contain deprecated geo_shape properties that must be removed",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_mappings_changes",
"mappings in component template my-template contains deprecated geo_shape properties. [parameter [geo_shape] in field " +
"[points_only]; parameter [geo_shape] in field [strategy]]", false, null)
"mappings in component template my-template contains deprecated geo_shape properties. [parameter [points_only] in field " +
"[location]; parameter [strategy] in field [location]]", false, null)
));

// Third, trying a component template and an index template:
Expand All @@ -433,10 +433,10 @@ public void testCheckGeoShapeMappings() throws Exception {
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"component templates and index templates contain deprecated geo_shape properties that must be removed",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_mappings_changes",
"mappings in component template my-template contains deprecated geo_shape properties. [parameter [geo_shape] in field " +
"[points_only]; parameter [geo_shape] in field [strategy]]; mappings in index template single-type contains " +
"deprecated geo_shape properties. [parameter [geo_shape] in field [points_only]; parameter [geo_shape] in field " +
"[strategy]]", false, null)
"mappings in component template my-template contains deprecated geo_shape properties. [parameter [points_only] in field " +
"[location]; parameter [strategy] in field [location]]; mappings in index template single-type contains " +
"deprecated geo_shape properties. [parameter [points_only] in field [location]; parameter [strategy] in field " +
"[location]]", false, null)
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@ public void testCheckGeoShapeMappings() throws Exception {
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"mappings for index test contains deprecated geo_shape properties that must be removed",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_mappings_changes",
"The following geo_shape parameters must be removed from test: [[parameter [geo_shape] in field [points_only]; parameter " +
"[geo_shape] in field [strategy]]]", false, null)
"The following geo_shape parameters must be removed from test: [[parameter [points_only] in field [location]; parameter " +
"[strategy] in field [location]]]", false, null)
));

Map<String, Object> nestedProperties = Stream.of(new Object[][] {
Expand All @@ -627,8 +627,8 @@ public void testCheckGeoShapeMappings() throws Exception {
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"mappings for index test contains deprecated geo_shape properties that must be removed",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_mappings_changes",
"The following geo_shape parameters must be removed from test: [[parameter [geo_shape] in field [points_only]; parameter " +
"[geo_shape] in field [strategy]]]", false, null)
"The following geo_shape parameters must be removed from test: [[parameter [points_only] in field [location]; parameter " +
"[strategy] in field [location]]]", false, null)
));
}
}