WARNING: Version 1.4 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Bool Query
editBool Query
editA query that matches documents matching boolean combinations of other
queries. The bool query maps to Lucene BooleanQuery
. It is built using
one or more boolean clauses, each clause with a typed occurrence. The
occurrence types are:
Occur | Description |
---|---|
|
The clause (query) must appear in matching documents. |
|
The clause (query) should appear in the matching document. In
a boolean query with no |
|
The clause (query) must not appear in the matching documents. |
The bool query also supports disable_coord
parameter (defaults to
false
). Basically the coord similarity computes a score factor based
on the fraction of all query terms that a document contains. See Lucene
BooleanQuery
for more details.
The bool
query takes a more-matches-is-better approach, so the score from
each matching must
or should
clause will be added together to provide the
final _score
for each document.
{ "bool" : { "must" : { "term" : { "user" : "kimchy" } }, "must_not" : { "range" : { "age" : { "from" : 10, "to" : 20 } } }, "should" : [ { "term" : { "tag" : "wow" } }, { "term" : { "tag" : "elasticsearch" } } ], "minimum_should_match" : 1, "boost" : 1.0 } }