2017-08-17 2 views
1

私はElasticSearchのバージョン5.4.1を使用しています。弾性サーチアグリゲーションで空のバケット配列を取得する

groupBy集約/集約集合を実行しようとすると、私はバケット配列に値を取得できません。

これが私のインデックスです:

curl -X PUT localhost:9200/urldata -d '{ 
    "mappings" : { 
     "components" : { 
      "properties" : { 
       "name" : { 
        "type" : "keyword", 
        "index" : "not_analyzed" 
       }, 
       "status" : { 
        "type" : "keyword", 
        "index" : "not_analyzed" 
       }, 
       "timestamp":{ 
        "type":"date", 
        "index":"not_analyzed" 
       } 
      } 
     } 
    } 
}' 

そして、この集計クエリ:

curl -XGET 'localhost:9200/urldata/_search?pretty' -H 'Content-Type: application/json' -d' 
    { 
     "size": 0, 
     "aggs": { 
     "components": { 
      "terms": { 
      "field": "name.keyword" 
      } 
     } 
     } 
    } 
    ' 

出力:私は間違っているつもりです

{ 
"took":2, 
    "timed_out":false, 
    "_shards":{ 
     "total":5, 
     "successful":5, 
     "failed":0 
    }, 
    "hits":{ 
     "total":3, 
     "max_score":0.0, 
     "hits":[ 

     ] 
    }, 
    "aggregations":{ 
     "components":{ 
     "doc_count_error_upper_bound":0, 
     "sum_other_doc_count":0, 
     "buckets":[ 

     ] 
     } 
    } 
} 

+0

いくつかの文書の例を提供できますか? – mel

+0

{name: "A"、ステータス: "success"、created_at: "2017-08-17"} {name: "A"、ステータス: "failure"、created_at: "2017-08-18"} –

答えて

1

これを試してみて、それはそれを行う必要があります。

{ 
    "size": 0, 
    "aggs": { 
    "components": { 
     "terms": { 
     "field": "name" 
     } 
    } 
    } 
} 

編集:ここでは

があなたのユースケースを複製するすべてのステップです:

PUT test 
{ 
    "settings" : { 
     "index" : { 
      "number_of_shards" : 1, 
      "number_of_replicas" : 0 
     } 
    } 
} 

PUT test/_mapping/people_name 
{ 
    "properties":{ 
     "name":{ 
     "type":"keyword", 
     "index":"not_analyzed" 
     }, 
     "status":{ 
     "type":"keyword", 
     "index":"not_analyzed" 
     }, 
     "timestamp":{ 
     "type":"date", 
     "index":"not_analyzed" 
     } 
    } 
} 

POST test/people_name 
{ 
    "name": "A", 
    "status": "success", 
    "created_at": "2017-08-17" 
} 

POST test/people_name 
{ 
    "name": "A", 
    "status": "success_2", 
    "created_at": "2017-06-15" 
} 

POST test/people_name 
{ 
    "name": "B", 
    "status": "success", 
    "created_at": "2017-09-15" 
} 

GET test/people_name/_search 
{ 
    "size": 0, 
    "aggs": { 
    "components": { 
     "terms": { 
     "field": "name" 
     } 
    } 
    } 
} 

集計結果:

{ 
    "took": 3, 
    "timed_out": false, 
    "_shards": { 
    "total": 1, 
    "successful": 1, 
    "failed": 0 
    }, 
    "hits": { 
    "total": 3, 
    "max_score": 0, 
    "hits": [] 
    }, 
    "aggregations": { 
    "components": { 
     "doc_count_error_upper_bound": 0, 
     "sum_other_doc_count": 0, 
     "buckets": [ 
     { 
      "key": "A", 
      "doc_count": 2 
     }, 
     { 
      "key": "B", 
      "doc_count": 1 
     } 
     ] 
    } 
    } 
} 
+0

これは例外です:{"error":{"root_cause":[{"type": "illegal_argument_exception"、 "reason": "デフォルトでテキストフィールドでフィールドデータが無効になりました。 –

+0

あなたはどちらのバージョンですか? – mel

+0

私はESバージョン5.4.1を使用しています。 –

関連する問題