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

disallow creating geo_shape mappings with deprecated parameters #70850

Merged
merged 13 commits into from
Apr 30, 2021

Conversation

iverase
Copy link
Contributor

@iverase iverase commented Mar 25, 2021

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.

@iverase iverase added >breaking :Analytics/Geo Indexing, search aggregations of geo points and shapes v8.0.0 labels Mar 25, 2021
@iverase iverase requested a review from romseygeek March 25, 2021 08:19
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Mar 25, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@iverase iverase mentioned this pull request Mar 25, 2021
22 tasks
Copy link
Contributor

@romseygeek romseygeek left a 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.

@@ -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");
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

@romseygeek romseygeek left a 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)) {
Copy link
Contributor

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.

Copy link
Contributor Author

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:

public final void testDeprecatedBoost() throws IOException {

It seems that checking of unknown parameters happen after the builder.

ywelsch pushed a commit that referenced this pull request Mar 26, 2021
…#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
@iverase
Copy link
Contributor Author

iverase commented Apr 29, 2021

@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 MapperTestCase which assume you can create those mappings in version 8.0.0:

testDeprecatedBoost: Do you have any suggestion here, I am not sure how to tackle it? Maybe we can introduce a method in MapperTestCase like supportsVersion(version) to check if we can run the test?

testIndexTimeStoredFieldsAccess: I add a check that we are creating a mapping service with the correct version.

protected MapperService createMapperService(XContentBuilder mappings) throws IOException {
Version version = VersionUtils.randomPreviousCompatibleVersion(random(), Version.V_8_0_0);
return createMapperService(version, mappings);
}
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works too. Implemented.

Copy link
Contributor

@romseygeek romseygeek left a 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.

@@ -655,6 +655,8 @@ public final void testIndexTimeStoredFieldsAccess() throws IOException {
minimalMapping(b);
b.field("store", true);
}));
assumeTrue("Mapper service is too old",
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

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(
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I added one

Copy link
Contributor Author

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.

Copy link
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @iverase!

jrodewig added a commit that referenced this pull request Jun 29, 2021
* 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
masseyke added a commit that referenced this pull request Sep 1, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >breaking Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants