-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
disallow creating geo_shape mappings with deprecated parameters #70850
Conversation
Pinging @elastic/es-analytics-geo (Team:Analytics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @iverase! I left a suggestion about how to improve the error message.
server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldTypeTests.java
Outdated
Show resolved
Hide resolved
@@ -452,6 +452,10 @@ public LegacyGeoShapeFieldMapper(String simpleName, MappedFieldType mappedFieldT | |||
super(simpleName, mappedFieldType, Collections.singletonMap(mappedFieldType.name(), Lucene.KEYWORD_ANALYZER), | |||
builder.ignoreMalformed.get(), builder.coerce.get(), builder.ignoreZValue.get(), builder.orientation.get(), | |||
multiFields, copyTo, indexer, parser); | |||
if (builder.indexCreatedVersion.onOrAfter(Version.V_8_0_0)) { | |||
throw new IllegalArgumentException("mapper [" + name() | |||
+ "] of type [geo_shape] with deprecated parameters is no longer allowed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to be a bit clearer about what is causing the error here. Maybe instead of having the version check here we should move it to containsDeprecatedParameter
so that the error message can explicitly contain the parameters that were used and are no longer allowed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I have done is to collect the used deprecated parameters in the builder so we can report back to the user. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better, thanks! I made one more suggestion but looks good otherwise.
@@ -452,7 +461,12 @@ public LegacyGeoShapeFieldMapper(String simpleName, MappedFieldType mappedFieldT | |||
super(simpleName, mappedFieldType, Collections.singletonMap(mappedFieldType.name(), Lucene.KEYWORD_ANALYZER), | |||
builder.ignoreMalformed.get(), builder.coerce.get(), builder.ignoreZValue.get(), builder.orientation.get(), | |||
multiFields, copyTo, indexer, parser); | |||
if (builder.indexCreatedVersion.onOrAfter(Version.V_8_0_0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this into the Builder constructor? The earlier we throw the better, in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried but I have issues with this test:
elasticsearch/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java
Line 270 in 91c700b
public final void testDeprecatedBoost() throws IOException { |
It seems that checking of unknown parameters happen after the builder.
…#70850) Searchable snapshots classes have been spread over multiple packages since the creation of the plugin's project (mea culpa). With the addition of the shared cache and other factorization of IndexInput's code it becomes less obvious to navigate the plugin codebase. Backport of #70814 for 7.12
@romseygeek, I have changed the approach and I throw an error as soon as possible (on the GeoShapeFieldMapper's type parser). I run into issue with two test on
|
protected MapperService createMapperService(XContentBuilder mappings) throws IOException { | ||
Version version = VersionUtils.randomPreviousCompatibleVersion(random(), Version.V_8_0_0); | ||
return createMapperService(version, mappings); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we also override createMapperService(Version, XContentBuilder)
and do an assumeFalse that the version is less than Version.V_8_0_0? It's final in the base class at the moment but I think it's fine to make it overrideable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works too. Implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of nits but we're nearly there I think.
server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java
Outdated
Show resolved
Hide resolved
@@ -655,6 +655,8 @@ public final void testIndexTimeStoredFieldsAccess() throws IOException { | |||
minimalMapping(b); | |||
b.field("store", true); | |||
})); | |||
assumeTrue("Mapper service is too old", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this check in the base class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we call the implementor for a service mapper and it can be returned theoretically in any version so we need to check, On the other hand we can force the implementor to return a specific version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It goes through createFieldMapper(XContentBuilder)
which is overridden in LegacyGeoShapeFieldMapperTests though, so we should already be picking a working version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but we are creating a working version with version < 8.0.0. For this test to work the version needs to be >= 8.0.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#72474 is merged so we should be able to remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Set<String> deprecatedParams = LegacyGeoShapeFieldMapper.getDeprecatedParameters(node.keySet()); | ||
throw new IllegalArgumentException("using deprecated parameters " + Arrays.toString(deprecatedParams.toArray()) | ||
+ " in mapper [" + name + "] of type [geo_shape] is no longer allowed"); | ||
} | ||
builder = new LegacyGeoShapeFieldMapper.Builder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a test for this?
For a followup: do we want to merge this class into GeoShape now that everything is basic licensed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I added one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of nits before merging them but yes, in the future we should merge them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @iverase!
* Removes docs and references for the following `geo_shape` mapping parameters: * `tree` * `tree_levels` * `strategy` * `distance_error_pct` * Updates a related breaking change. Relates to #70850
The following properties have been removed from the geo_shape data type in 8.0: "strategy", "tree", "tree_levels", "precision", "distance_error_pct", "points_only". This PR adds a deprecation info API check for indexes and templates that have any of these properties in their mappings. Relates #42404 #70850
With the introduction of BKD-based geo shape indexing in #32039, the prefix tree indexing method has been deprecated. From 8.0.0, it will not be allowed to create new mappings using deprecated parameters, and therefore all new mappings will be using the BKD indexing strategy.