summaryrefslogtreecommitdiff
path: root/docs/reference/query-dsl/filters/bool-filter.asciidoc
blob: bf36d264f9b64216743c5d3f701d8d9272fc32c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
[[query-dsl-bool-filter]]
=== Bool Filter

A filter that matches documents matching boolean combinations of other
queries. Similar in concept to
<<query-dsl-bool-query,Boolean query>>, except
that the clauses are other filters. Can be placed within queries that
accept a filter.

[source,js]
--------------------------------------------------
{
    "filtered" : {
        "query" : {
            "queryString" : { 
                "default_field" : "message", 
                "query" : "elasticsearch"
            }
        },
        "filter" : {
            "bool" : {
                "must" : {
                    "term" : { "tag" : "wow" }
                },
                "must_not" : {
                    "range" : {
                        "age" : { "from" : 10, "to" : 20 }
                    }
                },
                "should" : [
                    {
                        "term" : { "tag" : "sometag" }
                    },
                    {
                        "term" : { "tag" : "sometagtag" }
                    }
                ]
            }
        }
    }
}    
--------------------------------------------------

[float]
==== Caching

The result of the `bool` filter is not cached by default (though
internal filters might be). The `_cache` can be set to `true` in order
to enable caching.