Reputation: 3337
I'm trying to get all the the distinct values of a field in elasticsearch but I only get 10 buckets back.
I set my query like this:
GET /sdpjmx/kafkajmx/_search
{
"size": 0,
"aggs" : {
"topics" : {
"terms" : { "field" : "kafka_topic" }
}
}}
and even with the size
set to 0, I still only get 10 back.
results in this:
{
"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
}
]
}
}
}
Upvotes: 1
Views: 81
Reputation: 16335
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
}
}}
Upvotes: 2
Reputation: 2118
Try adding a size parameter inside the terms aggregation:
GET /sdpjmx/kafkajmx/_search
{
"size": 0,
"aggs" : {
"topics" : {
"terms" : {
"field" : "kafka_topic",
"size": 1000
}
}
}
}
Upvotes: 2