I am running an aggs query and specifying the size of 100, but ES only returns 10 buckets back. Why? What am I missing?
{
"size": 100
,"query": {
"bool": {
"must": [
{ "term": {"app": "cnn"} }
]
}
}
,"aggs": {
"unique_client": {
"terms": {"field": "client"}
}
}
}
Set the top size parameter to zero to signify that it is an aggregation. The number of buckets returned is set by specifying the size INSIDE the terms aggregation braces.
{
"size": 0
,"query": {
"bool": {
"must": [
{ "term": {"app": "cnn"} }
]
}
}
,"aggs": {
"unique_client": {
"terms": {
"field": "client",
"size" : 100
}
}
}
}
If you set it to 0 the value will default to Integer.MAX_VALUE
outer size is for total number of documents you get back for your query, so size = 100 returns 100 documents, for getting 100 aggregations bucket, specify size inside your unique_client aggs like this
{
"size": 0
,"query": {
"bool": {
"must": [
{ "term": {"app": "cnn"} }
]
}
}
,"aggs": {
"unique_client": {
"terms": {"field": "client"},
"size" : 100
}
}
}
By Default size of aggregations is 10, that is why you get 10 results, I have made outer size = 0 to get only aggregations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With