mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
Rewrite match_all inside must_not (#85999)
A must_not with a match_all clause inside a bool query is currently not rewritten to a match_none query. This means that running a boolean query with "must_not":[{"terms":{"_tier":["data_frozen","data_cold"]}] is currently not rewritten as match_none on a cold/frozen tier node.
This commit is contained in:
parent
718a241449
commit
4c47daa8d6
4 changed files with 18 additions and 9 deletions
|
@ -21,6 +21,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
|
|||
import org.elasticsearch.index.query.ConstantScoreQueryBuilder;
|
||||
import org.elasticsearch.index.query.DisMaxQueryBuilder;
|
||||
import org.elasticsearch.index.query.MatchAllQueryBuilder;
|
||||
import org.elasticsearch.index.query.MatchNoneQueryBuilder;
|
||||
import org.elasticsearch.index.query.MatchPhraseQueryBuilder;
|
||||
import org.elasticsearch.index.query.MatchQueryBuilder;
|
||||
import org.elasticsearch.index.query.Operator;
|
||||
|
@ -84,10 +85,10 @@ public class QueryBuilderBWCIT extends AbstractFullClusterRestartTestCase {
|
|||
""", new RangeQueryBuilder("long_field").from(1).to(9));
|
||||
addCandidate(
|
||||
"""
|
||||
"bool": { "must_not": [{"match_all": {}}], "must": [{"match_all": {}}], "filter": [{"match_all": {}}], \
|
||||
"bool": { "must_not": [{"match_none": {}}], "must": [{"match_all": {}}], "filter": [{"match_all": {}}], \
|
||||
"should": [{"match_all": {}}]}
|
||||
""",
|
||||
new BoolQueryBuilder().mustNot(new MatchAllQueryBuilder())
|
||||
new BoolQueryBuilder().mustNot(new MatchNoneQueryBuilder())
|
||||
.must(new MatchAllQueryBuilder())
|
||||
.filter(new MatchAllQueryBuilder())
|
||||
.should(new MatchAllQueryBuilder())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue