BoolQuery combines multiple subqueries into a single compound query using Boolean logic. Each subquery can be of any type, including another BoolQuery.
Data structure
message BoolQuery {
repeated Query must_queries = 1;
repeated Query must_not_queries = 2;
repeated Query filter_queries = 3;
repeated Query should_queries = 4;
optional int32 minimum_should_match = 5;
}
|
Parameter |
Type |
Required |
Description |
|
must_queries |
repeated Query |
No |
AND — subqueries that rows must satisfy. All conditions in this list must match. |
|
must_not_queries |
repeated Query |
No |
NOT — subqueries that rows must not satisfy. Rows matching any condition in this list are excluded. When multiple subqueries are specified, only rows that match none of them are returned — equivalent to NOT(A OR B). |
|
filter_queries |
repeated Query |
No |
AND (no scoring) — subqueries that rows must satisfy, similar to must_queries, but matches do not contribute to the relevance score. |
|
should_queries |
repeated Query |
No |
OR — optional subqueries that rows can satisfy. Rows must meet at least the number of conditions specified by minimum_should_match. Rows that satisfy more conditions receive a higher relevance score. |
|
minimum_should_match |
int32 |
No |
The minimum number of should_queries conditions a row must satisfy. If only should_queries is specified, the default is 1. If must_queries, must_not_queries, or filter_queries is also specified, the default is 0. |