forked from elastic/elasticsearch-definitive-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path70_Bool_query.json
68 lines (63 loc) · 1.03 KB
/
70_Bool_query.json
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Delete the `test` index
DELETE /test
# Insert some example docs
PUT /test/test/1
{
"title": "How to make millions!",
"tag": [
"opportunity"
],
"date": "2014-01-09"
}
PUT /test/test/2
{
"title": "How to make millions!",
"tag": [
"spam"
],
"date": "2014-01-09"
}
PUT /test/test/3
{
"title": "How to make millions!",
"tag": [
"opportunity",
"starred"
],
"date": "2013-01-09"
}
# Match "how to make millions" in the `title`
# and `tag` must not include "spam"
# and either `tag` should include "starred"
# or `date` must be >= "2014-01-01"
GET /test/test/_search
{
"query": {
"bool": {
"must": {
"match": {
"title": "how to make millions"
}
},
"must_not": {
"match": {
"tag": "spam"
}
},
"should": [
{
"match": {
"tag": "starred"
}
},
{
"range": {
"date": {
"gte": "2014-01-01"
}
}
}
]
}
}
}