我已经创建了一个索引,并在elasticsearch中为文档编制了索引,它运行良好,但这里的挑战是,我必须根据uniqueid获得类别字段的合计计数,我在下面给出了我的示例文档。
{
"UserID":"A1001",
"Category":"initiated",
"policyno":"5221"
},
{
"UserID":"A1001",
"Category":"pending",
"policyno":"5222"
},
{
"UserID":"A1001",
"Category":"pending",
"policyno":"5223"
},
{
"UserID":"A1002",
"Category":"completed",
"policyno":"5224"
}
**Sample output for UserID - "A1001"**
initiated-1
pending-2
**Sample output for UserID - "A1002"**
completed-1
如何从上述给定的json文档(如上面提到的示例输出)中获取聚合计数
1条答案
按热度按时间dz6r00yl1#
我建议使用如下所示的术语聚合:
以下是响应的一个片段: