ElasticSearch Version:6.2.2
Nested Aggregation
A special single bucket aggregation that enables aggregating nested documents.
一种特殊的单桶聚合,可聚合嵌套文档。Reverse nested Aggregation
A special single bucket aggregation that enables aggregating on parent docs from nested documents. Effectively this aggregation can break out of the nested block structure and link to other nested structures or the root document, which allows nesting other aggregations that aren’t part of the nested object in a nested aggregation.The reverse_nested aggregation must be defined inside a nested
aggregation.
一种特殊的单桶聚合,支持从嵌套文档中聚合父文档。实际上,这种聚合可以脱离嵌套块结构,并链接到其他嵌套结构或根文档,这允许嵌套不属于嵌套聚合中嵌套对象的其他聚合。reverse_nested聚合必须在嵌套聚合中定义。
DSL:
{
"size": 0,
"query": {
"bool": {
"filter": [{
"term": {
"params1": {
"value": 0,
"boost": 1.0
}
}
}, {
"nested": {
"query": {
"bool": {
"filter": [{
"bool": {
"should": [{
"bool": {
"filter": [{
"term": {
"nestedObject.params2": {
"value": 0,
"boost": 1.0
}
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}, {
"bool": {
"should": [{
"bool": {
"filter": [{
"term": {
"nestedObject.params2": {
"value": "1",
"boost": 1.0
}
}
}, {
"range": {
"nestedObject.params2Start": {
"from": null,
"to": "07:02:26",
"include_lower": true,
"include_upper": true,
"boost": 1.0
}
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}, {
"bool": {
"filter": [{
"term": {
"nestedObject.params2": {
"value": 1,
"boost": 1.0
}
}
}, {
"range": {
"nestedObject.params2End": {
"from": "07:02:26",
"to": null,
"include_lower": true,
"include_upper": true,
"boost": 1.0
}
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}, {
"bool": {
"filter": [{
"term": {
"nestedObject.params2": {
"value": 1,
"boost": 1.0
}
}
}, {
"range": {
"nestedObject.params2Start": {
"from": null,
"to": "07:02:26",
"include_lower": true,
"include_upper": true,
"boost": 1.0
}
}
}, {
"range": {
"nestedObject.params2End": {
"from": "07:02:26",
"to": null,
"include_lower": true,
"include_upper": true,
"boost": 1.0
}
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}, {
"bool": {
"should": [{
"bool": {
"filter": [{
"range": {
"nestedObject.params3": {
"from": "2020-05-07 07:02:26",
"to": null,
"include_lower": true,
"include_upper": true,
"boost": 1.0
}
}
}, {
"range": {
"nestedObject.params4": {
"from": null,
"to": "2020-05-07 07:02:26",
"include_lower": true,
"include_upper": true,
"boost": 1.0
}
}
}, {
"term": {
"nestedObject.params5": {
"value": 4,
"boost": 1.0
}
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}, {
"bool": {
"should": [{
"term": {
"nestedObject.params5": {
"value": 1,
"boost": 1.0
}
}
}, {
"term": {
"nestedObject.params5": {
"value": 2,
"boost": 1.0
}
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}],
"should": [{
"term": {
"nestedObject.params6": {
"value": 0,
"boost": 1.0
}
}
}, {
"term": {
"nestedObject.params6": {
"value": 1,
"boost": 1.0
}
}
}, {
"term": {
"nestedObject.params6": {
"value": 4,
"boost": 1.0
}
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
},
"path": "nestedObject",
"ignore_unmapped": false,
"score_mode": "none",
"boost": 1.0
}
}, {
"term": {
"params7": {
"value": "CN"
}
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
},
"_source": true,
"aggregations": {
"params7": {
"terms": {
"field": "params7",
"missing": "",
"size": 10000,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [{
"_count": "desc"
}, {
"_key": "asc"
}],
"collect_mode": "breadth_first"
},
"aggregations": {
"params8": {
"nested": {
"path": "nestedObject"
},
"aggregations": {
"packageType": {
"terms": {
"field": "nestedObject.params8"
},
"aggregations": {
"params5": {
"filter": {
"term": {
"nestedObject.params5": {
"value": 1,
"boost": 1.0
}
}
},
"aggregations": {
"params5sum": {
"sum": {
"field": "nestedObject.params5"
}
}
}
},
"params9": {
"reverse_nested": {},
"aggregations": {
"params9-1": {
"filter": {
"term": {
"params1": {
"value": 0,
"boost": 1.0
}
}
}
}
}
},
"params2": {
"filter": {
"nested": {
"query": {
"term": {
"nestedObject.params2": {
"value": 1,
"boost": 1.0
}
}
},
"path": "nestedObject",
"ignore_unmapped": false,
"score_mode": "none",
"boost": 1.0
}
}
}
}
}
}
}
}
}
}
}