我有文件,它看起来像如何过滤elasticsearch中的嵌套文档?
{
"_id": "56161cb3cbdad2e3b437fdc3",
"_type": "Comunity",
"name": "public",
"data": [
{
"title": "sonder",
"creationDate": "2015-08-22T03:43:28 -03:00",
"quantity": 0
},
{
"title": "vule",
"creationDate": "2014-05-17T12:35:01 -03:00",
"quantity": 0
},
{
"title": "omer",
"creationDate": "2015-01-31T04:54:19 -02:00",
"quantity": 3
},
{
"title": "sonder",
"creationDate": "2014-05-22T05:09:36 -03:00",
"quantity": 3
}
]
}
映射:
comunityDocument": {
"_source": {
"includes": [
"meta.*"
]
},
"properties": {
"doc": {
"dynamic": "false",
"properties": {
"data": {
"type": "nested",
"include_in_parent": true,
"properties": {
"title": {
"type": "string"
},
"creationDate": {
"type": "date",
"format": "dateOptionalTime"
},
"quantity": {
"type": "integer"
}
}
},
"name": {
"type": "string",
"index": "not_analyzed"
}
}
},
"meta": {
"include_in_all": false,
"properties": {
"expiration": {
"type": "long",
"include_in_all": false
},
"flags": {
"type": "long",
"include_in_all": false
},
"id": {
"type": "string",
"include_in_all": false
},
"rev": {
"type": "string",
"include_in_all": false
}
}
}
}
}
而且我的查询
{
"size": 0,
"aggs": {
"filterAgg": {
"filter": {
"nested": {
"path": "comunityDocument.doc.data",
"filter": {
"terms": {
"comunityDocument.doc.data.quantity": [
0
]
}
}
}
}
}
}
}
至于结果,我必须让所有的“数据”的计数的文件,其中数量等于0但我不明白。奇怪的事情,嵌套聚合工作,但不嵌套过滤器。
那是完整的映射吗? –