2017-03-17 66 views
0

我試圖在elasticsearch中獲得所有不同的字段值,但我只得到10個桶。elasticsearch不同的查詢只返回10個桶

設置我的查詢是這樣的:

GET /sdpjmx/kafkajmx/_search 
{ 
"size": 0, 
"aggs" : { 
    "topics" : { 
     "terms" : { "field" : "kafka_topic" } 
    } 
}} 

甚至與size設置爲0,我仍然只能得到10回。

結果在此:

{ 
    "took": 11, 
    "timed_out": false, 
    "_shards": { 
    "total": 3, 
    "successful": 3, 
    "failed": 0 
    }, 
    "hits": { 
    "total": 948380, 
    "max_score": 0, 
    "hits": [] 
    }, 
    "aggregations": { 
    "topics": { 
     "doc_count_error_upper_bound": 3597, 
     "sum_other_doc_count": 886819, 
     "buckets": [ 
     { 
      "key": "__consumer_offsets", 
      "doc_count": 10777 
     }, 
     { 
      "key": "EVENT_ONE", 
      "doc_count": 4367 
     }, 
     { 
      "key": "ERROR_AUTH", 
      "doc_count": 4365 
     }, 
     { 
      "key": "topic zds", 
      "doc_count": 4364 
     }, 
     { 
      "key": "topicabs", 
      "doc_count": 4360 
     }, 
     { 
      "key": "dynamictopic1", 
      "doc_count": 3827 
     }, 
     { 
      "key": "connect-a", 
      "doc_count": 3824 
     }, 
     { 
      "key": "topic12", 
      "doc_count": 3820 
     }, 
     { 
      "key": "service_qa", 
      "doc_count": 3820 
     }, 
     { 
      "key": "topic ad", 
      "doc_count": 3819 
     } 
     ] 
    } 
    } 
} 

回答

1

嘗試添加條款聚集內部尺寸參數:

GET /sdpjmx/kafkajmx/_search { "size": 0, "aggs" : { "topics" : { "terms" : { "field" : "kafka_topic", "size": 1000 } } } }

1
GET /sdpjmx/kafkajmx/_search 
{ 
"size": 0, //<-- This size is for query results and not agg results 
"aggs" : { 
    "topics" : { 
     "terms" : { "field" : "kafka_topic" }, 
     "size" : 0 //<-- it will return all aggregation terms 
    } 
}}