The behaviour of a query clause depends on whether it is used in query context or
in filter context:

Query context

A query clause used in query context answers the question “How well does this
document match this query clause?” Besides deciding whether or not the
document matches, the query clause also calculates a _score representing how
well the document matches, relative to other documents.

Query context is in effect whenever a query clause is passed to a query parameter,
such as the query parameter in the search API.

Filter context

In filter context, a query clause answers the question “Does this document
match this query clause?” The answer is a simple Yes or No — no scores are
calculated. Filter context is mostly used for filtering structured data, e.g.

Does this timestamp fall into the range 2015 to 2016?

Is the status field set to "published"?

Frequently used filters will be cached automatically by Elasticsearch, to
speed up performance.

Filter context is in effect whenever a query clause is passed to a filter
parameter, such as the filter or must_not parameters in the
bool query, the filter parameter in the
constant_score query, or the
filter aggregation.

Below is an example of query clauses being used in query and filter context
in the search API. This query will match documents where all of the following
conditions are met: