Skip to content

Convert geo field mappers to Parametrized form #63836

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

Merged
merged 16 commits into from
Oct 22, 2020

Conversation

romseygeek
Copy link
Contributor

Relates to #62988

@romseygeek romseygeek added :Search Foundations/Mapping Index mappings, including merging and defining field types >refactoring v8.0.0 v7.11.0 labels Oct 16, 2020
@romseygeek romseygeek self-assigned this Oct 16, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Oct 16, 2020
@romseygeek romseygeek requested a review from iverase October 19, 2020 13:41
@@ -54,6 +54,12 @@ public static SpatialStrategy fromString(String strategyName) {
return strategy;
}
}
return null;
throw new IllegalArgumentException("Unknown strategy [" + strategyName + "]");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ended up catching a pre-existing bug in GeoShapeQueryTests, which was asking for TERM instead of term as a strategy, and therefore ending up falling back on null here, which was getting translated to recursive once the mapper had been parsed. Silently falling back to recursive is a bug, I think, although on backport we will need to change this to emit a warning instead, as you can't change the strategy once it has been set and so existing mappings with badly-spelled term strategies will have to stay using recursive

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think this is a breaking change?

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'd say it was a bugfix rather than a breaking change, I think?

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 opened #63975 to emit a deprecation warning for this case in 7.x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Existing mappings sort of fix themselves, btw, so my above comment was not correct. Once a user has added a mapping with a bad strategy, it will serialize itself as recursive, so we don't need to worry about parsing mappings from previous versions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that is what I checked so the only change is that creating a mapping will throw an error when before it was successful.

? AbstractShapeGeometryFieldMapper.Defaults.IGNORE_Z_VALUE
: shapeMapper.ignoreZValue();
boolean coerce = shapeMapper != null && shapeMapper.coerce();
boolean ignoreZValue = shapeMapper == null || shapeMapper.ignoreZValue();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whether or not a parameter has been explicitly set is of interest only to the mapper itself, and its serialization code; the PR changes these getters on the mappers to return simple booleans.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

}
}

protected String[] getParseMinimalWarnings() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These needed to be changed to getters, rather than just asserting in themselves, so that the checks for deprecated boost parameters didn't get confused by the additional warnings.

@romseygeek
Copy link
Contributor Author

This is a big change, because unfortunately due to the class hierarchies I had to change all the geo mappers at the same time. On the plus side, these are the only remaining mappers to convert, so once this is done we can collapse FieldMapper and ParametrizedFieldMapper together and remove a lot of dead code.

@romseygeek romseygeek requested a review from nik9000 October 19, 2020 14:00
@romseygeek
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/packaging-sample-windows

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

Looks right to me but I left a request and a question. I genuinely don't know the answer to the question.

}

@Override
protected void addMultiFields(ParseContext context, Geometry geometry) {

Copy link
Member

Choose a reason for hiding this comment

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

It looks like the old code had a comment that this was intentionally a noop. I think it is worth keeping that.

@@ -186,12 +212,8 @@ public boolean equals(Object other) {
CartesianPoint o = (CartesianPoint)other;
oX = o.getX();
oY = o.getY();
} else if (other instanceof ParsedCartesianPoint == false) {
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to be equal to ParsedCartesianPoints?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we're comparing against a ParsedCartesianPoint, then the earlier instanceof CartesianPoint branch will already have matched, so this branch is never called.

Copy link
Member

Choose a reason for hiding this comment

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

++. I hadn't pulled it up.

@romseygeek
Copy link
Contributor Author

Thanks @nik9000, I added the comments back in.

Copy link
Contributor

@iverase iverase left a comment

Choose a reason for hiding this comment

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

LGTM, It is a nice simplification.

@romseygeek
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/packaging-sample-windows

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

@romseygeek
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/packaging-sample-windows

@romseygeek
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/default-distro (gradle download timeout)

@romseygeek
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/packaging-sample-windows

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>refactoring :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v7.11.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants