[英]Sub-Aggregations for Child documents in elasticsearch?
說我有一個父文件
curl -XPUT es-host:9200/index/parent_type/1 -d '{
"foo": "bar"
}'
我有一個孩子證件
curl -XPUT es-host:9200/index/child_type/?parent=1 -d '{
"child-foo-1": "child-bar-1",
"child-foo-2": "child-bar-2"
}'
有什么方法可以在父文檔聚合下獲取我的子文檔數據的子聚合,例如,
{
"aggregations": {
"foo-aggregations": {
"buckets": [
{
"key": "bar",
"doc_count": 1,
"child-foo-1-aggregations": {
"key": "child-bar-1",
"doc_count": 1
},
"child-foo-2-aggregations": {
"key": "child-bar-2",
"doc_count": 1
}
}
]
}
}
}
curl -XPOST 'localhost:9200/index/parent/_search?pretty' -d '
{
"size": "0",
"aggs" : {
"name" : {
"terms" : {
"field": "name.keyword"
},
"aggs" : {
"child_category": {
"children" : {
"type": "child_type_name"
},
"aggs" : {
"data" : {
"terms" : {
"field": "child_field_text.keyword"
}
}
}
}
}
}
}
}'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.