Reference · Cheat sheet

The bool query

The compressed essence. Print it, pin it.

From lesson 0006See also glossary

Four occurrence types

ClauseMeaningScores?Cached?SQL-ish
mustmust matchyesnoAND (scored)
shouldpreferably matchesyesnoOR / boost
filtermust matchnoyesAND (unscored)
must_notmust not matchnoyesAND NOT

Two rules to memorize

What should means (the gotcha)

Contextshould behaves as
with a must/filteroptional booster — re-ranks only, never filters
alone (no must/filter)required matcher — acts like OR (≥1 must match)

Canonical placement

bool {
  must:     full-text relevance      // scored
  should:   optional boosters          // scored, re-rank
  filter:   exact / range / enum       // unscored, cached
  must_not: exclusions                 // unscored, cached
}

Relevance → must/should. Yes/no constraints → filter. Exclusions → must_not.

← lesson 0006 · Source: Query DSL — Boolean query