Take the 2-minute tour ×

is there a way to get the "top 10" facets but at the same time get all the possible facets we could have created (in that case, all distinct kingdoms in our document).

I know I could increase the "size" to a very big number, but then it generates a very big JSON and processing costs may be much bigger.

A simple facet...

"facets" : {
    "kingdom": {
        "terms": {
            "field": "kingdom",
            "size": 10

thanks in advance

share|improve this question
How can you get all the potential entries without receiving a big JSON back? Could you please clarify what you mean? –  javanna Sep 18 '12 at 10:51
i mean, i don't want to get something like {term:kingdom1, count:100} for each possible facet (kingdom). This would be the big JSON I told you. I just want the first ten 'kingdoms' (the more 'popular'), with its name and counts, but get also some info about how many possible facets I could have generated. In SQL it sould be something like 'select count(distinct(kingdom)) from...' –  user1249791 Sep 18 '12 at 11:32
add comment

1 Answer

the size of the json response is proportional to the amount of different values you have for that term.

with that being said i believe what you want is to apply a sort


there will be two queries, the "facets" :{"kingdom":{"terms":{"field": "kingdom","size": 10}} will return you all of the terms and the other query will return the first 10 order descending inside the "hits" field

share|improve this answer
add comment

Your Answer


