1,使用filter 以及 filters 的一些过滤
filter过滤
{
"aggs": {
"t_shirts": {
"filter": { "term": { "SOURCETYPE": "0" } },
"aggs": {
"term": { "avg": { "field": "TITLE.KEYWORD" } }
}
}
}
}
filters过滤
{
"size": 0,
"aggs" : {
"messages" : {
"filters" : {
"filters" : {
"errors" : { "match" : { "SOURCETYPE" : "0" }},
"warnings" : { "match" : { "SOURCETYPE" : "1" }}
}
}
}
}
}
other_bucket_key 参数使用
{
"size": 0,
"aggs" : {
"messages" : {
"filters" : {
"other_bucket_key": "other_messages",
"filters" : {
"errors" : { "match" : { "SOURCETYPE" : "0" }},
"warnings" : { "match" : { "SOURCETYPE" : "1" }}
}
}
}
}
}
结果
"aggregations": {
"messages": {
"buckets": {
"errors": {
"doc_count": 388704
},
"warnings": {
"doc_count": 299
},
"other_messages": {
"doc_count": 180121
}
}
}
}
公众号: