这是我的文档的样子。
{
"Summary": "The One Way You're Putting Pressure on Your Partner Without Realizing It=20",
"Industry" : "Lifestyle and Fitness",
"Name": "Kali Coleman",
"Email" : "query-bixh@helpareporter.net",
"Media Outlet": "Best Life Online"
},
{
"Summary": "The One Way You're Putting Pressure on",
"Industry" : "High Tech",
"Name": "John Smith",
"Email" : "query-tech@helpareporter.net",
"Media Outlet": "Anonymous"
}
我想对每种类型的";工业;领域这是我想要的输出。
{
"key": "Lifestyle and Fitness",
"count": 1200
},
{
"key": "High Tech",
"count": 590
}
我在这里发现了一个类似的帖子,ElasticSearch统计了多个字段的分组,只是我不必过滤。我在Kibana控制台上尝试了一下,结果出现了以下错误。
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [Industry] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
]
如果有人知道这个问题的解决方案,请告诉我。
感谢
您可以像示例中那样使用terms
聚合,您可以在不使用过滤器的情况下这样做。一旦您将Industry
字段的映射配置为keyword
类型,就可以运行
GET index_name/_search
{
"size": 0,
"aggs": {
"by_industry": {
"terms": {
"field": "Industry.keyword"
}
}
}
}