disallow creating geo_shape mappings with deprecated parameters#70850
disallow creating geo_shape mappings with deprecated parameters#70850iverase merged 13 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/es-analytics-geo (Team:Analytics) |
romseygeek
left a comment
There was a problem hiding this comment.
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
| 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.
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.
What I have done is to collect the used deprecated parameters in the builder so we can report back to the user. wdyt?
romseygeek
left a comment
There was a problem hiding this comment.
Much better, thanks! I made one more suggestion but looks good otherwise.
| 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.
Can we move this into the Builder constructor? The earlier we throw the better, in general.
There was a problem hiding this comment.
I have tried but I have issues with this test:
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.
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.
That works too. Implemented.
romseygeek
left a comment
There was a problem hiding this comment.
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
| minimalMapping(b); | ||
| b.field("store", true); | ||
| })); | ||
| assumeTrue("Mapper service is too old", |
There was a problem hiding this comment.
Do we still need this check in the base class?
There was a problem hiding this comment.
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.
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.
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.
#72474 is merged so we should be able to remove this
| 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.
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.
There are a couple of nits before merging them but yes, in the future we should merge them.
romseygeek
left a comment
There was a problem hiding this comment.
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.