-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Refactor of GeoPolygonQuery #13426
Refactor of GeoPolygonQuery #13426
Conversation
@Override | ||
protected Query doToQuery(QueryShardContext context) throws IOException { | ||
|
||
if (!shell.get(shell.size() - 1).equals(shell.get(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.
I'd slightly prefer to do this before or into a copy of the shape? I think only the latter is possible though, not sure. Also, maybe it is not a big deal to auto close and change the original shape...
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 don't think it's going to be possible to do this before the toQuery method. I can copy the shape but these shapes can be big and complex so I'd only want to do that if we need to. I guess one side effect of doing this here is that two QueryBuilders which are identical before the toQuery method is called (pass hashCode and Equals checks) would then not be equal after calling toQuery on only one of them. So actually maybe we should make a copy here? I'm torn
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 am thinking it is not worth it. Hopefully it won't cause problems to our test infra as we don't check the object after calling toQuery...... should we have done it in the first place? :)
left a few minor comments, looks good already though |
@javanna I pushed a commit to address your comments |
|
||
private Boolean ignoreMalformed; | ||
public GeoPolygonQueryBuilder(String fieldName) { | ||
this.fieldName = fieldName; |
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 just call this(fieldName, new ArrayList());
instead?
left some minors - looks great |
@s1monw thanks for the review. I've push a new commit that should address all your comments |
LGTM |
// percolation queries we only ignore_malformed on 2.x created indexes | ||
if (!indexCreatedBeforeV2_0 && !ignoreMalformed) { | ||
for (GeoPoint point : shell) { | ||
if (point.lat() > 90.0 || point.lat() < -90.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.
Maybe add a note to switch to https://github.com/elastic/elasticsearch/pull/11969/files#diff-6236367b2788d500f308334adc6d4d7fR70 once that PR is 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.
I'll make a new change to use this once that PR has been pushed
Moving the query building functionality from the parser to the builders new toQuery() method analogous to other recent query refactorings. Relates to #10217 PR goes against the query-refactoring branch
Moving the query building functionality from the parser to the builders
new toQuery() method analogous to other recent query refactorings.
Relates to #10217
PR goes against the query-refactoring branch