gpt4 book ai didi

elasticsearch - Elasticsearch中子文档的子集合?

转载 作者:行者123 更新时间:2023-12-02 22:41:45 25 4
gpt4 key购买 nike

说我有一个父文件

curl -XPUT es-host:9200/index/parent_type/1 -d '{

"foo": "bar"
}'

我有一个 child 证件
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"
}

}
}
}
}
}
}
}'

关于elasticsearch - Elasticsearch中子文档的子集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24078843/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com