#48475 Pure disjunctions should rewrite to a MatchNoneQueryBuilder#48557
#48475 Pure disjunctions should rewrite to a MatchNoneQueryBuilder#48557jpountz merged 9 commits intoelastic:masterfrom
Conversation
SivagurunathanV
commented
Oct 27, 2019
- Added Pure disjunctions should rewrite to a MatchNoneQueryBuilder when all instance matches MatchNoneQueryBuilder
- Added testcase for the same.
|
@SivagurunathanV we already rewrite |
|
@SivagurunathanV The linked issue is about optional clauses while your PR handles required clauses. If you don't understand how the issue should be addressed, please raise questions before opening a pull request. |
|
@SivagurunathanV Yes indeed. One important factor is that SHOULD clauses behave differently depending on whether there are any required (MUST or FILTER) clauses, so we will need to be carefull with this. |
|
@jpountz Thanks for the explanation. Based on my understanding, if the required clauses are empty and the optional clause is returning MatchNone, we can safely make an early termination. |
|
@SivagurunathanV Yes, if there are no required clauses and all SHOULD clauses rewrite to a MatchNoneQueryBuilder then the bool query can rewrite to a MatchNoneQueryBuilder. |
|
@jpountz Thanks. Added my changes to the PR. Please let me know if that works. |
|
Pinging @elastic/es-search (:Search/Search) |
jpountz
left a comment
There was a problem hiding this comment.
Thanks, the change looks good to me! I'll merge this PR next week.
|
@jpountz Can you merge this PR? |
|
Oops, thanks for the reminder, I'll merge soon. |
|
@elasticmachine ok to test |
| changed |= rewriteClauses(queryRewriteContext, filterClauses, newBuilder::filter); | ||
| changed |= rewriteClauses(queryRewriteContext, shouldClauses, newBuilder::should); | ||
| // early termination when must clause is empty and optional clauses is returning MatchNoneQueryBuilder | ||
| if(mustClauses.size() == 0 && filterClauses.size() == 0 |
There was a problem hiding this comment.
Given test failures, I think the problem is that this rewrites empty boolean queries to a match_none, while this is currently treated as a match_all. We probably to do something like below, can you add a unit test for this case?
| if(mustClauses.size() == 0 && filterClauses.size() == 0 | |
| if (mustClauses.size() == 0 && filterClauses.size() == 0 && shouldClauses.size() > 0 |
There was a problem hiding this comment.
Thanks for the catch. I just updated the code. Let me know.
|
@jpountz I am not able to see the failed job logs in Jenkins, can you please help me here. what is the exact issue. Thanks |
|
@elasticmachine ok to test |
|
@SivagurunathanV The logs don't require authentication or anything, so you should be able to read them. Some tests were complaining that the matching documents were not the expected ones. |
|
user doesn't have permission to update head repository |
|
@SivagurunathanV Would you mind merging master into your branch? |
|
@jpountz Thanks for the help. I merged the master into my branch and all test passed :) |
|
@elasticmachine ok to test |
|
Thanks @SivagurunathanV ! |