Get all the facet aggregate results

HI,

I am new to elastic search.
I was doing some research on facet when I stumbled upon a problem where I need all the aggregated data based on a search query.
Currently the facet return only the first 10 aggregated data.

Example:
curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
{
"query" : { "query_string" : {"query" : "*"} },
"size":0,
"facets" : {
"tags" : { "terms" : {"field" : "country" } }
}
}'

On running this I get
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 29324,
"max_score" : 1.0,
"hits" : [ ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 0,
"total" : 29324,
"other" : 8570,
"terms" : [ {
"term" : "United States",
"count" : 8081
}, {
"term" : "United Kingdom",
"count" : 3768
}, {
"term" : "Spain",
"count" : 1779
},{
"term" : "Uganda",
"count" : 1639
}, {
"term" : "Brazil",
"count" : 1541
}, {
"term" : "Canada",
"count" : 1176
}, {
"term" : "Kenya",
"count" : 834
}, {
"term" : "South Africa",
"count" : 831
}, {
"term" : "Indonesia",
"count" : 729
}, {
"term" : "Nigeria",
"count" : 376
} ]
}
}
}

Now as you can see the facet aggregates are just 10, what should I do to get all the aggregates.

Thanks,
Cyril

Hi,

Here is a solution for your question.

set the size attribute inside the terms

curl -XPOST 'localhost:9200/posts/_search?pretty=true' -d '
{
"query" : {
"term" : { "content" : "obama" }
},
"facets" : {
"tag" : {
"terms" : { "field" : "country",
"size" : 1000,
"all_terms" : false }

}
}
}
'
here the all_terms if true: shows all the countries corresponding to the terms { even if the country count is zero }

Thanks,
Rahul

Thanks it worked for me!