0
我在一个索引中有来自不同应用程序的文档,应用程序名称是每个文档中的一个字段。现在我想要统计每个应用程序每天的文档数量。应用程序名称采用字符串格式,因此我无法使用过滤条件。 虽然低于GET查询每层可以combine query_string和聚合
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "+environmentType:prod +application:app1",
"analyze_wildcard": true
}
}
}
}
}
过滤,我可以用这个聚集了简单的日常计数
{
"aggs": {
"simpleDatehHistogram": {
"date_histogram": {
"field": "timestamp",
"interval": "day"
}
}
}
}
我似乎不能够把它们结合在一起,使应用程序过滤器应用于我的聚合结果。
这是我的索引映射。
{
"myIndex" : {
"mappings" : {
"myType" : {
"properties" : {
"application" : {
"type" : "string"
},
"environmentType" : {
"type" : "string"
},
"event" : {
"properties" : {
"Id" : {
"type" : "long"
},
"documentId" : {
"type" : "string"
},
}
},
"hostname" : {
"type" : "string"
},
"id" : {
"type" : "string"
},
"timestamp" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"timestampEpoch" : {
"type" : "long"
},
"type" : {
"type" : "string"
},
"version" : {
"type" : "string"
}
}
}
}
}
}
这是我真实目的是试图的第一件事情,但结果是相同的,无论我的应用程序的名称,所以我想这是不是应用的过滤器。 .. – Acalypha
你可以只发布你的索引映射。 'GET index/type/_mapping' – Richa
我刚刚尝试过上面的查询,它确实在上面应用查询的基础上为我带来了聚合桶。你能详细解释一下吗? – Richa