这是存在于ElasticSearch中的文档,它希望输出基于字段的值,在这些字段中,它返回高位和中位数之和,如果这些值大于零,则高位和中位数的值必须大于0
{
"host_id": 1,
"hostname": "Hostname1",
"businesshierarchy": {
"businessunit": "NON Unit",
"Location":"Un",
"Application":"App1"
},
"updatedts": 1601894092,
"critical": 0,
"high": 1,
"medium": 1,
"low": 0
},
{
"host_id": 2,
"hostname": "Hostname2",
"businesshierarchy": {
"businessunit": "One Unit",
"Location":"Un",
"Application":"App2"
},
"updatedts": 1601894092,
"critical": 0,
"high": 1,
"medium": 2,
"low": 0
},
{
"host_id": 3,
"hostname": "Hostname3",
"businesshierarchy": {
"businessunit": "NON Unit",
"Location":"Uk",
"Application":"App2"
},
"updatedts": 1601894092,
"critical": 0,
"high": 2,
"medium": 2,
"low": 0
}
是否有任何查询或方法可以像ElasticSearch那样获得输出?
基于位置
位置-un高-2中-3
位置-英国高-2中-2
基于应用
应用程序-app1 high-1 medium-1
应用程序-app2 high-3 medium-4
或基于主机名
主机名-主机名1高-1中-1
主机名-主机名2高-1中-2
主机名-主机名3高-2中-2
businessunit也是如此。动态传递的字段名(如businessunit、hostname、application、location-based)希望获得count high和medium值(如上面的输出)。
2条答案
按热度按时间aij0ehis1#
我们可以使用这个查询来获得例外的结果
搜索结果如下
如果我们需要定位和应用的结果,只需要更改定位
申请
如果Map是这样的,
没有必要将.keyword添加到
mspsb9vt2#
添加一个使用索引Map、索引数据(与前面给出的相同)、搜索查询和搜索结果的工作示例
索引Map:
搜索查询:
搜索结果:
根据位置
对于基于应用程序替换项聚合的查询,如下所示:
将显示以下搜索结果:
对于基于主机名替换项聚合的查询,如下所示:
搜索结果将是: