2017-04-06 66 views
0

我有我的索引嵌套類型的映射:elasticsearch 5嵌套長期聚集不起作用

"actors": { 
      "type": "nested", 
      "properties": { 
       "actor": { 
       "type": "nested", 
       "properties": { 
        "actor_full_name": { 
        "type": "text", 
        "fields": { 
         "keyword": { 
         "type": "keyword", 
         "ignore_above": 256 
         } 
        } 
        } 
       } 
       } 
      } 
      } 

當我看到DATAS它看起來是好的

請求

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": [] 
     } 
    } 
    } 

你明白我做錯了,我該如何修復它?

回答

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 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
}