-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Refactors TermsQueryBuilder and Parser #12042
Refactors TermsQueryBuilder and Parser #12042
Conversation
* @param objs the Iterable of input object | ||
* @return the same input or a list of utf8 string if input was a list of type {@link BytesRef} | ||
*/ | ||
protected static List<Object> convertToStringListIfBytesRefList(Iterable objs) { |
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.
not a big fan of these two new methods to be honest. Maybe since they are needed in one query only we can loop there instead?
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.
not a big fan either, but note we do use convertToStringListIfBytesRefList
in two places. So I moved them to the builder instead.
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.
so the alternative is looping in two places instead in TermsQueryBuilder? I think I would go for that.
I did a first review, can you please rebase and address comments? Also, I would like to know from @s1monw and @jpountz what they think about having a Client within IndexQueryParseService, like we are adding here, so that we can retrieve it through QueryShardContext and execute the needed get calls (still on the data node). Wonder if there's any other/better way, I couldn't come up with any. |
@javanna Thanks for the review. Just a couple of notes here.
I think we should only document the change in migrate doc for 2) and 3) |
0815151
to
671e7c7
Compare
@javanna rebased and addressed comments. We should still figure out how best to mock a handleTermsLookup or a Client in our test. This will also be useful for queries such as MLT. Thanks for the review. |
671e7c7
to
3651c99
Compare
} | ||
|
||
Query query; | ||
if (context.isFilter()) { // NO COMMIT: not exactly sure how to handle this case, right now using a filter flag |
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 think this is ok used this way, @cbuescher do you agree ?
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 think this is ok, the isFilter() flag should be set when parent queries that are already using toQuery() produce some inner query in a filter context.
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.
cool then remove the NOCOMMIT here?
/** | ||
* Helper method to return a random field (mapped or unmapped) and a value | ||
*/ | ||
protected Tuple<String, Object> getRandomFieldNameAndValue(String... exclude) { |
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.
Same here as above, since both methods are related and read similar.
This is much closer now I did another round of review and left some comments |
} catch (IllegalArgumentException e) { | ||
assertThat(e.getMessage(), Matchers.containsString("No value specified for terms query")); | ||
} | ||
} |
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 add a test that verifies that if you specify both terms_lookup and values on the REST layer we get back a validation error? This part in the parser seems a bit tricky, I want to make sure we don't lose this.
b92d0c3
to
9b8eef6
Compare
@javanna I addressed all the comments. Hopefully it should be good to go. Thank you for the review. |
public TermsQueryBuilder(String name, Iterable values) { | ||
this.name = name; | ||
this.values = values; | ||
public TermsQueryBuilder(String fieldName, Iterable values) { |
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.
Iterable<Object>
I did a last review round, left some minor comments. LGTM otherwise |
@@ -56,21 +63,118 @@ public String getId() { | |||
return id; | |||
} | |||
|
|||
public String getPath() { |
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.
last super small comment, can we remove the get prefix from these setters from now, for consistency reasons?
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 like to but it would break bwc. Mark them as deprecated?
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 doesn't break anything given that this class was only used internally, it was not part of the java api. Only this change makes it part of the java api.
left one tiny comment, LGTM though |
Refactors TermsQueryBuilder and Parser for elastic#10217. This PR is against the query-refactoring branch. Closes elastic#12042
7f3d530
to
1af0a39
Compare
Refactors TermsQueryBuilder and Parser for #10217. Also removes deprecated
TermsLookupQuery class and unused or deprecated options
execution
,min_should_match
,lookup_cache
.This PR is against the query-refactoring branch.