我的索引中有一个嵌套类型映射:
"actors": {
"type": "nested",
"properties": {
"actor": {
"type": "nested",
"properties": {
"actor_full_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
当我看到数据时,它看起来没问题
请求
GET /test_index/film/_search
{
"size": 100,
"_source": "actors.actor.actor_full_name"
}
给我这个答案:
"actors": {
"actor": [
{
"actor_full_name": "Antonio BANDERAS"
},
{
"actor_full_name": "Diane VENORA"
},
{
"actor_full_name": "Omar SHARIF"
},
{
"actor_full_name": "Vladimir KULICH"
}
]
},
...
我正在尝试在actor_full_name字段
上执行nested aggregation request我正在尝试此请求:
POST /test_index/film/_search
{
"size": 0,
"aggs": {
"actor_nested_agg_code": {
"nested": {
"path": "actors"
},
"aggs": {
"code_actor_agg": {
"terms": {
"field": "actor.actor_full_name.keyword",
"size": 100
}
}
}
}
}
}
不幸的是,它似乎给了我一个incorect aswere:
"aggregations": {
"actor_nested_agg_code": {
"doc_count": 1807,
"code_actor_agg": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
}
}
}
你看到我做错了什么以及如何解决它吗?
答案 0 :(得分:1)
你要么也不想让actors
嵌套,要么你忽略了那里有两个nested
字段:
{
"size": 0,
"aggs": {
"actor_nested_agg_code": {
"nested": {
"path": "actors"
},
"aggs": {
"second_nested_actor": {
"nested": {
"path": "actors.actor"
},
"aggs": {
"code_actor_agg": {
"terms": {
"field": "actors.actor.actor_full_name.keyword",
"size": 100
}
}
}
}
}
}
}
}