6
我正在尝试对数组中的值进行聚合,并筛选由前缀返回的存储区。不知道这是可能的还是我滥用过滤器桶。ElasticSearch从数组字段中过滤聚合
3个文件:
{ "colors":["red","black","blue"] }
{ "colors":["red","black"] }
{ "colors":["red"] }
的目标是获得具有彩色文档开头字母B计数:
{
"size":0,
"aggs" : {
"colors" : {
"filter" : { "prefix" : { "colors" : "b" } },
"aggs" : {
"top-colors" : { "terms" : { "field":"colors" } }
}
}
}
}
也说回来包括红不幸的结果。很明显,因为红色的文档仍然通过过滤器匹配,因为它们也有蓝色和/或黑色。
"aggregations": {
"colors": {
"doc_count": 2,
"top-colors": {
"buckets": [
{
"key": "black",
"doc_count": 2
},
{
"key": "red",
"doc_count": 2
},
{
"key": "blue",
"doc_count": 1
}
]
}
}
}
有没有一种方法可以过滤桶结果?
Woops,不知道我怎么错过了在该文档中,谢谢! – scott