-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Conversation
Pinging @elastic/es-search (:Search/Mapping) |
@@ -54,6 +54,12 @@ public static SpatialStrategy fromString(String strategyName) { | |||
return strategy; | |||
} | |||
} | |||
return null; | |||
throw new IllegalArgumentException("Unknown strategy [" + strategyName + "]"); | |||
} |
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.
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
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 you think this is a breaking change?
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'd say it was a bugfix rather than a breaking change, I think?
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 opened #63975 to emit a deprecation warning for this case in 7.x
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.
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.
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, 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(); |
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.
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.
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.
+1
} | ||
} | ||
|
||
protected String[] getParseMinimalWarnings() { |
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.
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.
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. |
@elasticmachine run elasticsearch-ci/packaging-sample-windows |
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.
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) { | ||
|
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 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) { |
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.
We don't need to be equal to ParsedCartesianPoint
s?
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.
If we're comparing against a ParsedCartesianPoint
, then the earlier instanceof CartesianPoint
branch will already have matched, so this branch is never called.
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 hadn't pulled it up.
Thanks @nik9000, I added the comments back in. |
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, It is a nice simplification.
@elasticmachine run elasticsearch-ci/packaging-sample-windows |
@elasticmachine update branch |
@elasticmachine run elasticsearch-ci/packaging-sample-windows |
@elasticmachine run elasticsearch-ci/default-distro (gradle download timeout) |
@elasticmachine run elasticsearch-ci/packaging-sample-windows |
@elasticmachine update branch |
Relates to #62988