Boolean query

Boolean query #

A query that matches documents matching boolean combinations of other queries. It is built using one or more boolean clauses.

Inside a nested query: supported — must/filter/should/must_not and minimum_should_match all apply within ONE array element; clauses matched by different elements never combine.

Examples #

POST /my-collection/_search
{
  "query": {
    "bool": {
      "must": [
        { "match": { "field": "title", "query": "search" } }
      ],
      "filter": [
        { "term": { "field": "status", "value": "published" } }
      ],
      "must_not": [
        { "range": { "field": "views", "gte": 100000 } }
      ],
      "should": [
        { "term": { "field": "tags", "value": "featured" } }
      ],
      "minimum_should_match": 1
    }
  }
}

Clause types #

  • must
    The document must match. Contributes to the score.
  • filter
    The document must match. Does not contribute to the score — results may be cached by filter context.
  • should
    The document should match. Contributes to the score; required to match only when no must/filter clauses are present (then at least one should must match) or when minimum_should_match is set.
  • must_not
    The document must not match. Does not contribute to the score.

Parameters for bool #

  • minimum_should_match
    (Optional, integer) Minimum number of should clauses a document must match. The built-in default is 1 when the query has should clauses but no must/filter, otherwise 0.
  • score_mode
    (Optional, string) Multi-field score combination strategy for should clauses: most_fields (sum — the default, for backward compatibility) or best_fields (max, dis_max style).
  • tie_breaker
    (Optional, float, default: 0) Tie-breaker for best_fields mode. Final score: max_score + tie_breaker * sum(other_scores). Range [0, 1].
  • combination_strategy
    (Optional, string) Score combination strategy for should clauses across fields (best_fields or most_fields).
Calendar September 27, 2026
Edit Edit this page