bodybuilder()
.query('match', 'message', 'this is a test')
.filter('term', 'user', 'kimchy')
.filter('term', 'user', 'herald')
.orFilter('term', 'user', 'johnny')
.notFilter('term', 'user', 'cassie')
.aggregation('terms', 'user')
.build()
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"term": {
"user": "kimchy"
}
},
{
"term": {
"user": "herald"
}
}
],
"should": [
{
"term": {
"user": "johnny"
}
}
],
"must_not": [
{
"term": {
"user": "cassie"
}
}
]
}
},
"must": {
"match": {
"message": "this is a test"
}
}
}
},
"aggs": {
"agg_terms_user": {
"terms": {
"field": "user"
}
}
}
}