我试图在 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
}
]
}
}
}
尝试在术语聚合中添加大小参数:
GET /sdpjmx/kafkajmx/_search
{
"size": 0,
"aggs" : {
"topics" : {
"terms" : {
"field" : "kafka_topic",
"size": 1000
}
}
}
}
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
}
}}