This works.
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{ "term" : { "keywords" : "google" } },
{ "term" : { "keywords" : "microsoft" } },
{ "term" : { "keywords" : "tesla" } }
],
"minimum_should_match": 1,
"must": [
{ "range": {
"@timestamp": {
"gte": "now-5d/d",
"lte": "now",
"format": "date_optional_time"
}
}
}
]
}}
]
}
},
"aggs": {
"uniq_uuids": {
"terms": {
"field": "user_uuid.keyword",
"size": 10000
}
}
}
}
But when I try to add another bool inside must array, it returns zero hits. See below:
POST _search
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{ "term" : { "keywords" : "google" } },
{ "term" : { "keywords" : "microsoft" } },
{ "term" : { "keywords" : "tesla" } }
],
"minimum_should_match": 1,
"must": [
{ "range": {
"@timestamp": {
"gte": "now-5d/d",
"lte": "now",
"format": "date_optional_time"
}
}
}
]
}},
{"bool": {
"should": [
{ "term" : { "keywords" : "apple" } },
{ "term" : { "keywords" : "youtube" } },
{ "term" : { "keywords" : "spotify" } }
],
"minimum_should_match": 1,
"must": [
{ "range": {
"@timestamp": {
"gte": "now-9d/d",
"lte": "now",
"format": "date_optional_time"
}
}
}
]
}}
]
}
},
"aggs": {
"uniq_uuids": {
"terms": {
"field": "user_uuid.keyword",
"size": 10000
}
}
}
}