2017-04-06 3 views
0

を動作しません:私は件のデータが表示されたらelasticsearch 5ネストされた用語の集約は、私は私のインデックスにネストされた型のマッピングを持って

"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" 
    } 
OKになりそうです

私にこの答えを与える:

"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が同様に入れ子に作ることを意味するものではありませんでしたか、あなたはそこに2つの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 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 
関連する問題