环境:windows 10 ,ES 7.5
需求:查询子文档,聚合子文档对应的父文档
故障:如下语句聚合统计父文档的都是为1
假设我该查询出来有子文档有532多条数据,然后就8个分类(父文档),但聚合出来 的8个分类数量却是1
{
"from": 0,
"size": 0,
"query": {
"bool": {
"must": [
{
"has_parent": {
"parent_type": "myParent",
"score": true,
"query": {
"bool": {
"must": [
{
"term": {
"myfield": "6"
}
}
]
}
}
}
},
{
"term": {
"myField": "分类"
}
}
]
}
},
"aggs": {
"page": {
"parent": {
"type": "myChild"
},
"aggs": {
"tags": {
"terms": {
"script": "doc['_id'].value",
"size": 100
}
}
}
}
}
}
3 个回复
hubiao
赞同来自:
laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net
赞同来自:
一点点核查原因及问题所在。
hubiao
赞同来自: