# Terms facet, getting all the results?

**URL:** https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607
**Category:** Elasticsearch
**Created:** [June 10, 2011, 10:24pm UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607 "2011-06-10T22:24:44Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Adrian\_Gaudebert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrian_gaudebert/32/3161_2.png) [@Adrian\_Gaudebert](https://discuss.elastic.co/u/Adrian_Gaudebert)
#### Post date: [June 10, 2011, 10:24pm UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607/1 "2011-06-10T22:24:44Z")

</div>

Hi there!

_Long story short:_

Is there a way to retrieve every result of a terms facet? Something like "size"  
: "\_all"? Or do I have to trick and use "size" : 9999999?

_Long story long:_

I have a bunch of documents that look like this:  
{  
"signature" : "something",  
"os" : "linux" // or "windows" or "mac"...  
}

The signature field is not analyzed. There are other fields that don't  
matter here. Documents can share the same signature, and that is the point.

What I am trying to do is getting the distinct signatures, and for each  
signature the total count and the count by OS. My solution so far is to  
query (I actually search things in the other fields, but it doesn't matter  
here) a bunch of documents, and apply terms facets.

Here is what my JSON query looks like:

{  
"size" : 0,  
"query" : {  
"match\_all" : {}  
},  
"facets" : {  
"sign" : {  
"terms" : {  
"field" : "signature"  
}  
},  
"sign\_win" : {  
"terms" : {  
"field" : "signature"  
},  
"facet\_filter" : {  
"term" : {  
"os\_name" : "windows"  
}  
}  
},  
...  
}

This works. This gives me almost the data I want. The last problem is that I  
need to get only a part of this big set of data. I want to be able to do  
something similar to a "size" / "from" but for the facet. And if, as I  
believe, it is not possible with ES, I would like to retrieve every result  
of the facets, and then apply the size / from in my code.

Am I doing it wrong? Is there something I don't know about that would solve  
my problem? What is the Ultimate Question of Life, the Universe, and  
Everything?

Thanks for your help!

--  
Adrian Gaudebert  
WebDev Intern @ Mozilla  
[http://adrian.gaudebert.fr](http://adrian.gaudebert.fr)

---

<div class="post-metadata">

### Author: ![Kun\_Niu](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@Kun\_Niu](https://discuss.elastic.co/u/Kun_Niu)
#### Post date: [June 10, 2011, 10:31pm UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607/2 "2011-06-10T22:31:17Z")

</div>

Does setSize(int size) work for you?  
It's a method of SearchRequestBuilder if you're using Java.

On Jun 10, 3:24 pm, Adrian Gaudebert [adrian.gaudeb...@gmail.com](mailto:adrian.gaudeb...@gmail.com)  
wrote:

> Hi there!
> 
> _Long story short:_
> 
> Is there a way to retrieve every result of a terms facet? Something like "size"  
> : "\_all"? Or do I have to trick and use "size" : 9999999?
> 
> _Long story long:_
> 
> I have a bunch of documents that look like this:  
> {  
> "signature" : "something",  
> "os" : "linux" // or "windows" or "mac"...
> 
> }
> 
> The signature field is not analyzed. There are other fields that don't  
> matter here. Documents can share the same signature, and that is the point.
> 
> What I am trying to do is getting the distinct signatures, and for each  
> signature the total count and the count by OS. My solution so far is to  
> query (I actually search things in the other fields, but it doesn't matter  
> here) a bunch of documents, and apply terms facets.
> 
> Here is what my JSON query looks like:
> 
> {  
> "size" : 0,  
> "query" : {  
> "match\_all" : {}  
> },  
> "facets" : {  
> "sign" : {  
> "terms" : {  
> "field" : "signature"  
> }  
> },  
> "sign\_win" : {  
> "terms" : {  
> "field" : "signature"  
> },  
> "facet\_filter" : {  
> "term" : {  
> "os\_name" : "windows"  
> }  
> }  
> },  
> ...
> 
> }
> 
> This works. This gives me almost the data I want. The last problem is that I  
> need to get only a part of this big set of data. I want to be able to do  
> something similar to a "size" / "from" but for the facet. And if, as I  
> believe, it is not possible with ES, I would like to retrieve every result  
> of the facets, and then apply the size / from in my code.
> 
> Am I doing it wrong? Is there something I don't know about that would solve  
> my problem? What is the Ultimate Question of Life, the Universe, and  
> Everything?
> 
> Thanks for your help!
> 
> --  
> Adrian Gaudebert  
> WebDev Intern @ Mozillahttp://adrian.gaudebert.fr

---

<div class="post-metadata">

### Author: ![Adrian\_Gaudebert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrian_gaudebert/32/3161_2.png) [@Adrian\_Gaudebert](https://discuss.elastic.co/u/Adrian_Gaudebert)
#### Post date: [June 10, 2011, 10:37pm UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607/3 "2011-06-10T22:37:08Z")

</div>

I'm using Python. But the thing I want to know is if there is a "good" way  
of doing that. Or to solve my problem.

I guess Python also have some method to get the max integer value, which I  
could use if there is nothing better to do...

On Fri, Jun 10, 2011 at 3:31 PM, kun niu [haoniukun@gmail.com](mailto:haoniukun@gmail.com) wrote:

> Does setSize(int size) work for you?  
> It's a method of SearchRequestBuilder if you're using Java.
> 
> On Jun 10, 3:24 pm, Adrian Gaudebert [adrian.gaudeb...@gmail.com](mailto:adrian.gaudeb...@gmail.com)  
> wrote:
> 
> > Hi there!
> > 
> > _Long story short:_
> > 
> > Is there a way to retrieve every result of a terms facet? Something like  
> > "size"  
> > : "\_all"? Or do I have to trick and use "size" : 9999999?
> > 
> > _Long story long:_
> > 
> > I have a bunch of documents that look like this:  
> > {  
> > "signature" : "something",  
> > "os" : "linux" // or "windows" or "mac"...
> > 
> > }
> > 
> > The signature field is not analyzed. There are other fields that don't  
> > matter here. Documents can share the same signature, and that is the  
> > point.
> > 
> > What I am trying to do is getting the distinct signatures, and for each  
> > signature the total count and the count by OS. My solution so far is to  
> > query (I actually search things in the other fields, but it doesn't  
> > matter  
> > here) a bunch of documents, and apply terms facets.
> > 
> > Here is what my JSON query looks like:
> > 
> > {  
> > "size" : 0,  
> > "query" : {  
> > "match\_all" : {}  
> > },  
> > "facets" : {  
> > "sign" : {  
> > "terms" : {  
> > "field" : "signature"  
> > }  
> > },  
> > "sign\_win" : {  
> > "terms" : {  
> > "field" : "signature"  
> > },  
> > "facet\_filter" : {  
> > "term" : {  
> > "os\_name" : "windows"  
> > }  
> > }  
> > },  
> > ...
> > 
> > }
> > 
> > This works. This gives me almost the data I want. The last problem is  
> > that I  
> > need to get only a part of this big set of data. I want to be able to do  
> > something similar to a "size" / "from" but for the facet. And if, as I  
> > believe, it is not possible with ES, I would like to retrieve every  
> > result  
> > of the facets, and then apply the size / from in my code.
> > 
> > Am I doing it wrong? Is there something I don't know about that would  
> > solve  
> > my problem? What is the Ultimate Question of Life, the Universe, and  
> > Everything?
> > 
> > Thanks for your help!
> > 
> > --  
> > Adrian Gaudebert  
> > WebDev Intern @ Mozillahttp://adrian.gaudebert.fr

--  
Adrian Gaudebert  
WebDev Intern @ Mozilla  
[http://adrian.gaudebert.fr](http://adrian.gaudebert.fr)

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [June 12, 2011, 7:14am UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607/4 "2011-06-12T07:14:54Z")

</div>

There isn't an option to say bring be all terms back, you can open an issue and it can be added. Though, you should be careful with responses that return a large amount of data.

On Saturday, June 11, 2011 at 1:37 AM, Adrian Gaudebert wrote:

> I'm using Python. But the thing I want to know is if there is a "good" way of doing that. Or to solve my problem.
> 
> I guess Python also have some method to get the max integer value, which I could use if there is nothing better to do...
> 
> On Fri, Jun 10, 2011 at 3:31 PM, kun niu \<[haoniukun@gmail.com](mailto:haoniukun@gmail.com) ([mailto:haoniukun@gmail.com](mailto:haoniukun@gmail.com))\> wrote:
> 
> > Does setSize(int size) work for you?  
> > It's a method of SearchRequestBuilder if you're using Java.
> > 
> > On Jun 10, 3:24 pm, Adrian Gaudebert \<[adrian.gaudeb...@gmail.com](mailto:adrian.gaudeb...@gmail.com) ([mailto:adrian.gaudeb...@gmail.com](mailto:adrian.gaudeb...@gmail.com))\>  
> > wrote:
> > 
> > > Hi there!
> > > 
> > > _Long story short:_
> > > 
> > > Is there a way to retrieve every result of a terms facet? Something like "size"  
> > > : "\_all"? Or do I have to trick and use "size" : 9999999?
> > > 
> > > _Long story long:_
> > > 
> > > I have a bunch of documents that look like this:  
> > > {  
> > > "signature" : "something",  
> > > "os" : "linux" // or "windows" or "mac"...
> > > 
> > > }
> > > 
> > > The signature field is not analyzed. There are other fields that don't  
> > > matter here. Documents can share the same signature, and that is the point.
> > > 
> > > What I am trying to do is getting the distinct signatures, and for each  
> > > signature the total count and the count by OS. My solution so far is to  
> > > query (I actually search things in the other fields, but it doesn't matter  
> > > here) a bunch of documents, and apply terms facets.
> > > 
> > > Here is what my JSON query looks like:
> > > 
> > > {  
> > > "size" : 0,  
> > > "query" : {  
> > > "match\_all" : {}  
> > > },  
> > > "facets" : {  
> > > "sign" : {  
> > > "terms" : {  
> > > "field" : "signature"  
> > > }  
> > > },  
> > > "sign\_win" : {  
> > > "terms" : {  
> > > "field" : "signature"  
> > > },  
> > > "facet\_filter" : {  
> > > "term" : {  
> > > "os\_name" : "windows"  
> > > }  
> > > }  
> > > },  
> > > ...
> > > 
> > > }
> > > 
> > > This works. This gives me almost the data I want. The last problem is that I  
> > > need to get only a part of this big set of data. I want to be able to do  
> > > something similar to a "size" / "from" but for the facet. And if, as I  
> > > believe, it is not possible with ES, I would like to retrieve every result  
> > > of the facets, and then apply the size / from in my code.
> > > 
> > > Am I doing it wrong? Is there something I don't know about that would solve  
> > > my problem? What is the Ultimate Question of Life, the Universe, and  
> > > Everything?
> > > 
> > > Thanks for your help!
> > > 
> > > --  
> > > Adrian Gaudebert  
> > > WebDev Intern @ Mozillahttp://adrian.gaudebert.fr
> 
> --  
> Adrian Gaudebert  
> WebDev Intern @ Mozilla  
> [http://adrian.gaudebert.fr](http://adrian.gaudebert.fr)

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [June 12, 2011, 10:12am UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607/5 "2011-06-12T10:12:35Z")

</div>

Is there any way to get the total number of all other results ?

Such as : (let's say I want only the Top 2 So I set the size of the facet to 2)  
Windows : 5  
Linux : 3  
Others : 10

The firsts two are the main elements.  
The last one is the others elements.

Number total of facets = 5+3+10

thanks

David

Le 12 juin 2011 à 09:14, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) a écrit :

> There isn't an option to say bring be all terms back, you can open an issue and it can be added. Though, you should be careful with responses that return a large amount of data.  
> On Saturday, June 11, 2011 at 1:37 AM, Adrian Gaudebert wrote:
> 
> > I'm using Python. But the thing I want to know is if there is a "good" way of doing that. Or to solve my problem.
> > 
> > I guess Python also have some method to get the max integer value, which I could use if there is nothing better to do...
> > 
> > On Fri, Jun 10, 2011 at 3:31 PM, kun niu [haoniukun@gmail.com](mailto:haoniukun@gmail.com) wrote:
> > 
> > > Does setSize(int size) work for you?  
> > > It's a method of SearchRequestBuilder if you're using Java.
> > > 
> > > On Jun 10, 3:24 pm, Adrian Gaudebert [adrian.gaudeb...@gmail.com](mailto:adrian.gaudeb...@gmail.com)  
> > > wrote:
> > > 
> > > > Hi there!
> > > > 
> > > > _Long story short:_
> > > > 
> > > > Is there a way to retrieve every result of a terms facet? Something like "size"  
> > > > : "\_all"? Or do I have to trick and use "size" : 9999999?
> > > > 
> > > > _Long story long:_
> > > > 
> > > > I have a bunch of documents that look like this:  
> > > > {  
> > > > "signature" : "something",  
> > > > "os" : "linux" // or "windows" or "mac"...
> > > > 
> > > > }
> > > > 
> > > > The signature field is not analyzed. There are other fields that don't  
> > > > matter here. Documents can share the same signature, and that is the point.
> > > > 
> > > > What I am trying to do is getting the distinct signatures, and for each  
> > > > signature the total count and the count by OS. My solution so far is to  
> > > > query (I actually search things in the other fields, but it doesn't matter  
> > > > here) a bunch of documents, and apply terms facets.
> > > > 
> > > > Here is what my JSON query looks like:
> > > > 
> > > > {  
> > > > "size" : 0,  
> > > > "query" : {  
> > > > "match\_all" : {}  
> > > > },  
> > > > "facets" : {  
> > > > "sign" : {  
> > > > "terms" : {  
> > > > "field" : "signature"  
> > > > }  
> > > > },  
> > > > "sign\_win" : {  
> > > > "terms" : {  
> > > > "field" : "signature"  
> > > > },  
> > > > "facet\_filter" : {  
> > > > "term" : {  
> > > > "os\_name" : "windows"  
> > > > }  
> > > > }  
> > > > },  
> > > > ...
> > > > 
> > > > }
> > > > 
> > > > This works. This gives me almost the data I want. The last problem is that I  
> > > > need to get only a part of this big set of data. I want to be able to do  
> > > > something similar to a "size" / "from" but for the facet. And if, as I  
> > > > believe, it is not possible with ES, I would like to retrieve every result  
> > > > of the facets, and then apply the size / from in my code.
> > > > 
> > > > Am I doing it wrong? Is there something I don't know about that would solve  
> > > > my problem? What is the Ultimate Question of Life, the Universe, and  
> > > > Everything?
> > > > 
> > > > Thanks for your help!
> > > > 
> > > > --  
> > > > Adrian Gaudebert  
> > > > WebDev Intern @ Mozillahttp://adrian.gaudebert.fr
> > 
> > --  
> > Adrian Gaudebert  
> > WebDev Intern @ Mozilla  
> > [http://adrian.gaudebert.fr](http://adrian.gaudebert.fr)

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [June 12, 2011, 11:10am UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607/6 "2011-06-12T11:10:52Z")

</div>

Not sure if I understood what exactly you are after, but you can have "count" facets using the query or filter facets.

On Sunday, June 12, 2011 at 1:12 PM, David Pilato wrote:

> Is there any way to get the total number of all other results ?
> 
> Such as : (let's say I want only the Top 2 So I set the size of the facet to 2)  
> Windows : 5  
> Linux : 3  
> Others : 10
> 
> The firsts two are the main elements.  
> The last one is the others elements.
> 
> Number total of facets = 5+3+10
> 
> thanks
> 
> David
> 
> Le 12 juin 2011 à 09:14, Shay Banon \<[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) ([mailto:shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com))\> a écrit :
> 
> > There isn't an option to say bring be all terms back, you can open an issue and it can be added. Though, you should be careful with responses that return a large amount of data.
> > 
> > On Saturday, June 11, 2011 at 1:37 AM, Adrian Gaudebert wrote:
> > 
> > > I'm using Python. But the thing I want to know is if there is a "good" way of doing that. Or to solve my problem.
> > > 
> > > I guess Python also have some method to get the max integer value, which I could use if there is nothing better to do...
> > > 
> > > On Fri, Jun 10, 2011 at 3:31 PM, kun niu \<[haoniukun@gmail.com](mailto:haoniukun@gmail.com) ([mailto:haoniukun@gmail.com](mailto:haoniukun@gmail.com))\> wrote:
> > > 
> > > > Does setSize(int size) work for you?  
> > > > It's a method of SearchRequestBuilder if you're using Java.
> > > > 
> > > > On Jun 10, 3:24 pm, Adrian Gaudebert \<[adrian.gaudeb...@gmail.com](mailto:adrian.gaudeb...@gmail.com) ([mailto:adrian.gaudeb...@gmail.com](mailto:adrian.gaudeb...@gmail.com))\>  
> > > > wrote:
> > > > 
> > > > > Hi there!
> > > > > 
> > > > > _Long story short:_
> > > > > 
> > > > > Is there a way to retrieve every result of a terms facet? Something like "size"  
> > > > > : "\_all"? Or do I have to trick and use "size" : 9999999?
> > > > > 
> > > > > _Long story long:_
> > > > > 
> > > > > I have a bunch of documents that look like this:  
> > > > > {  
> > > > > "signature" : "something",  
> > > > > "os" : "linux" // or "windows" or "mac"...
> > > > > 
> > > > > }
> > > > > 
> > > > > The signature field is not analyzed. There are other fields that don't  
> > > > > matter here. Documents can share the same signature, and that is the point.
> > > > > 
> > > > > What I am trying to do is getting the distinct signatures, and for each  
> > > > > signature the total count and the count by OS. My solution so far is to  
> > > > > query (I actually search things in the other fields, but it doesn't matter  
> > > > > here) a bunch of documents, and apply terms facets.
> > > > > 
> > > > > Here is what my JSON query looks like:
> > > > > 
> > > > > {  
> > > > > "size" : 0,  
> > > > > "query" : {  
> > > > > "match\_all" : {}  
> > > > > },  
> > > > > "facets" : {  
> > > > > "sign" : {  
> > > > > "terms" : {  
> > > > > "field" : "signature"  
> > > > > }  
> > > > > },  
> > > > > "sign\_win" : {  
> > > > > "terms" : {  
> > > > > "field" : "signature"  
> > > > > },  
> > > > > "facet\_filter" : {  
> > > > > "term" : {  
> > > > > "os\_name" : "windows"  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > ...
> > > > > 
> > > > > }
> > > > > 
> > > > > This works. This gives me almost the data I want. The last problem is that I  
> > > > > need to get only a part of this big set of data. I want to be able to do  
> > > > > something similar to a "size" / "from" but for the facet. And if, as I  
> > > > > believe, it is not possible with ES, I would like to retrieve every result  
> > > > > of the facets, and then apply the size / from in my code.
> > > > > 
> > > > > Am I doing it wrong? Is there something I don't know about that would solve  
> > > > > my problem? What is the Ultimate Question of Life, the Universe, and  
> > > > > Everything?
> > > > > 
> > > > > Thanks for your help!
> > > > > 
> > > > > --  
> > > > > Adrian Gaudebert  
> > > > > WebDev Intern @ Mozillahttp://adrian.gaudebert.fr
> > > 
> > > --  
> > > Adrian Gaudebert  
> > > WebDev Intern @ Mozilla  
> > > [http://adrian.gaudebert.fr](http://adrian.gaudebert.fr)

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [June 12, 2011, 12:04pm UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607/7 "2011-06-12T12:04:52Z")

</div>

Sorry for my english !!! ☹

I have docs with terms like term1, term2, term3, term4, term5, term6.

Term1 is used once  
Term2 twice,  
Term3 : 3 Times  
Term4 : 4 Times  
Term5 : 5 Times  
Term6 : 6 Times  
Term7 : 7 Times

When i use a term facet, i get :  
Term3 : 3  
Term4 : 4  
Term5 : 5  
Term6 : 6  
Term7 : 7

What i would like to have in the same facet results :  
Term3 : 3  
Term4 : 4  
Term5 : 5  
Term6 : 6  
Term7 : 7  
Others : 3

Others is the sum of term1 count (1) and term2 count (2).

If it still not clear, i Will provide a full user story or test case in the next days.

Thanks  
David 😉

Le 12 juin 2011 à 13:10, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) a écrit :

> Not sure if I understood what exactly you are after, but you can have "count" facets using the query or filter facets.  
> On Sunday, June 12, 2011 at 1:12 PM, David Pilato wrote:
> 
> > Is there any way to get the total number of all other results ?
> > 
> > Such as : (let's say I want only the Top 2 So I set the size of the facet to 2)  
> > Windows : 5  
> > Linux : 3  
> > Others : 10
> > 
> > The firsts two are the main elements.  
> > The last one is the others elements.
> > 
> > Number total of facets = 5+3+10
> > 
> > thanks
> > 
> > David
> > 
> > Le 12 juin 2011 à 09:14, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) a écrit :
> > 
> > > There isn't an option to say bring be all terms back, you can open an issue and it can be added. Though, you should be careful with responses that return a large amount of data.  
> > > On Saturday, June 11, 2011 at 1:37 AM, Adrian Gaudebert wrote:
> > > 
> > > > I'm using Python. But the thing I want to know is if there is a "good" way of doing that. Or to solve my problem.
> > > > 
> > > > I guess Python also have some method to get the max integer value, which I could use if there is nothing better to do...
> > > > 
> > > > On Fri, Jun 10, 2011 at 3:31 PM, kun niu [haoniukun@gmail.com](mailto:haoniukun@gmail.com) wrote:
> > > > 
> > > > > Does setSize(int size) work for you?  
> > > > > It's a method of SearchRequestBuilder if you're using Java.
> > > > > 
> > > > > On Jun 10, 3:24 pm, Adrian Gaudebert [adrian.gaudeb...@gmail.com](mailto:adrian.gaudeb...@gmail.com)  
> > > > > wrote:
> > > > > 
> > > > > > Hi there!
> > > > > > 
> > > > > > _Long story short:_
> > > > > > 
> > > > > > Is there a way to retrieve every result of a terms facet? Something like "size"  
> > > > > > : "\_all"? Or do I have to trick and use "size" : 9999999?
> > > > > > 
> > > > > > _Long story long:_
> > > > > > 
> > > > > > I have a bunch of documents that look like this:  
> > > > > > {  
> > > > > > "signature" : "something",  
> > > > > > "os" : "linux" // or "windows" or "mac"...
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > The signature field is not analyzed. There are other fields that don't  
> > > > > > matter here. Documents can share the same signature, and that is the point.
> > > > > > 
> > > > > > What I am trying to do is getting the distinct signatures, and for each  
> > > > > > signature the total count and the count by OS. My solution so far is to  
> > > > > > query (I actually search things in the other fields, but it doesn't matter  
> > > > > > here) a bunch of documents, and apply terms facets.
> > > > > > 
> > > > > > Here is what my JSON query looks like:
> > > > > > 
> > > > > > {  
> > > > > > "size" : 0,  
> > > > > > "query" : {  
> > > > > > "match\_all" : {}  
> > > > > > },  
> > > > > > "facets" : {  
> > > > > > "sign" : {  
> > > > > > "terms" : {  
> > > > > > "field" : "signature"  
> > > > > > }  
> > > > > > },  
> > > > > > "sign\_win" : {  
> > > > > > "terms" : {  
> > > > > > "field" : "signature"  
> > > > > > },  
> > > > > > "facet\_filter" : {  
> > > > > > "term" : {  
> > > > > > "os\_name" : "windows"  
> > > > > > }  
> > > > > > }  
> > > > > > },  
> > > > > > ...
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > This works. This gives me almost the data I want. The last problem is that I  
> > > > > > need to get only a part of this big set of data. I want to be able to do  
> > > > > > something similar to a "size" / "from" but for the facet. And if, as I  
> > > > > > believe, it is not possible with ES, I would like to retrieve every result  
> > > > > > of the facets, and then apply the size / from in my code.
> > > > > > 
> > > > > > Am I doing it wrong? Is there something I don't know about that would solve  
> > > > > > my problem? What is the Ultimate Question of Life, the Universe, and  
> > > > > > Everything?
> > > > > > 
> > > > > > Thanks for your help!
> > > > > > 
> > > > > > --  
> > > > > > Adrian Gaudebert  
> > > > > > WebDev Intern @ Mozillahttp://adrian.gaudebert.fr
> > > > 
> > > > --  
> > > > Adrian Gaudebert  
> > > > WebDev Intern @ Mozilla  
> > > > [http://adrian.gaudebert.fr](http://adrian.gaudebert.fr)

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [June 14, 2011, 9:08am UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607/8 "2011-06-14T09:08:11Z")

</div>

Ahh, I see. Make sense, can you open an issue for this?

On Sunday, June 12, 2011 at 3:04 PM, David Pilato wrote:

> Sorry for my english !!! ☹
> 
> I have docs with terms like term1, term2, term3, term4, term5, term6.
> 
> Term1 is used once  
> Term2 twice,  
> Term3 : 3 Times  
> Term4 : 4 Times  
> Term5 : 5 Times  
> Term6 : 6 Times  
> Term7 : 7 Times
> 
> When i use a term facet, i get :  
> Term3 : 3  
> Term4 : 4  
> Term5 : 5  
> Term6 : 6  
> Term7 : 7
> 
> What i would like to have in the same facet results :  
> Term3 : 3  
> Term4 : 4  
> Term5 : 5  
> Term6 : 6  
> Term7 : 7  
> Others : 3
> 
> Others is the sum of term1 count (1) and term2 count (2).
> 
> If it still not clear, i Will provide a full user story or test case in the next days.
> 
> Thanks  
> David 😉
> 
> Le 12 juin 2011 à 13:10, Shay Banon \<[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) ([mailto:shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com))\> a écrit :
> 
> > Not sure if I understood what exactly you are after, but you can have "count" facets using the query or filter facets.
> > 
> > On Sunday, June 12, 2011 at 1:12 PM, David Pilato wrote:
> > 
> > > Is there any way to get the total number of all other results ?
> > > 
> > > Such as : (let's say I want only the Top 2 So I set the size of the facet to 2)  
> > > Windows : 5  
> > > Linux : 3  
> > > Others : 10
> > > 
> > > The firsts two are the main elements.  
> > > The last one is the others elements.
> > > 
> > > Number total of facets = 5+3+10
> > > 
> > > thanks
> > > 
> > > David
> > > 
> > > Le 12 juin 2011 à 09:14, Shay Banon \<[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) ([mailto:shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com))\> a écrit :
> > > 
> > > > There isn't an option to say bring be all terms back, you can open an issue and it can be added. Though, you should be careful with responses that return a large amount of data.
> > > > 
> > > > On Saturday, June 11, 2011 at 1:37 AM, Adrian Gaudebert wrote:
> > > > 
> > > > > I'm using Python. But the thing I want to know is if there is a "good" way of doing that. Or to solve my problem.
> > > > > 
> > > > > I guess Python also have some method to get the max integer value, which I could use if there is nothing better to do...
> > > > > 
> > > > > On Fri, Jun 10, 2011 at 3:31 PM, kun niu \<[haoniukun@gmail.com](mailto:haoniukun@gmail.com) ([mailto:haoniukun@gmail.com](mailto:haoniukun@gmail.com))\> wrote:
> > > > > 
> > > > > > Does setSize(int size) work for you?  
> > > > > > It's a method of SearchRequestBuilder if you're using Java.
> > > > > > 
> > > > > > On Jun 10, 3:24 pm, Adrian Gaudebert \<[adrian.gaudeb...@gmail.com](mailto:adrian.gaudeb...@gmail.com) ([mailto:adrian.gaudeb...@gmail.com](mailto:adrian.gaudeb...@gmail.com))\>  
> > > > > > wrote:
> > > > > > 
> > > > > > > Hi there!
> > > > > > > 
> > > > > > > _Long story short:_
> > > > > > > 
> > > > > > > Is there a way to retrieve every result of a terms facet? Something like "size"  
> > > > > > > : "\_all"? Or do I have to trick and use "size" : 9999999?
> > > > > > > 
> > > > > > > _Long story long:_
> > > > > > > 
> > > > > > > I have a bunch of documents that look like this:  
> > > > > > > {  
> > > > > > > "signature" : "something",  
> > > > > > > "os" : "linux" // or "windows" or "mac"...
> > > > > > > 
> > > > > > > }
> > > > > > > 
> > > > > > > The signature field is not analyzed. There are other fields that don't  
> > > > > > > matter here. Documents can share the same signature, and that is the point.
> > > > > > > 
> > > > > > > What I am trying to do is getting the distinct signatures, and for each  
> > > > > > > signature the total count and the count by OS. My solution so far is to  
> > > > > > > query (I actually search things in the other fields, but it doesn't matter  
> > > > > > > here) a bunch of documents, and apply terms facets.
> > > > > > > 
> > > > > > > Here is what my JSON query looks like:
> > > > > > > 
> > > > > > > {  
> > > > > > > "size" : 0,  
> > > > > > > "query" : {  
> > > > > > > "match\_all" : {}  
> > > > > > > },  
> > > > > > > "facets" : {  
> > > > > > > "sign" : {  
> > > > > > > "terms" : {  
> > > > > > > "field" : "signature"  
> > > > > > > }  
> > > > > > > },  
> > > > > > > "sign\_win" : {  
> > > > > > > "terms" : {  
> > > > > > > "field" : "signature"  
> > > > > > > },  
> > > > > > > "facet\_filter" : {  
> > > > > > > "term" : {  
> > > > > > > "os\_name" : "windows"  
> > > > > > > }  
> > > > > > > }  
> > > > > > > },  
> > > > > > > ...
> > > > > > > 
> > > > > > > }
> > > > > > > 
> > > > > > > This works. This gives me almost the data I want. The last problem is that I  
> > > > > > > need to get only a part of this big set of data. I want to be able to do  
> > > > > > > something similar to a "size" / "from" but for the facet. And if, as I  
> > > > > > > believe, it is not possible with ES, I would like to retrieve every result  
> > > > > > > of the facets, and then apply the size / from in my code.
> > > > > > > 
> > > > > > > Am I doing it wrong? Is there something I don't know about that would solve  
> > > > > > > my problem? What is the Ultimate Question of Life, the Universe, and  
> > > > > > > Everything?
> > > > > > > 
> > > > > > > Thanks for your help!
> > > > > > > 
> > > > > > > --  
> > > > > > > Adrian Gaudebert  
> > > > > > > WebDev Intern @ Mozillahttp://adrian.gaudebert.fr
> > > > > 
> > > > > --  
> > > > > Adrian Gaudebert  
> > > > > WebDev Intern @ Mozilla  
> > > > > [http://adrian.gaudebert.fr](http://adrian.gaudebert.fr)

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [June 14, 2011, 11:48am UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607/9 "2011-06-14T11:48:02Z")

</div>

Here we go : [https://github.com/elasticsearch/elasticsearch/issues/1029](https://github.com/elasticsearch/elasticsearch/issues/1029)

BTW, it seems that I found an issue while creating the test case.  
I will open a new thread with a gist for that.

Thanks

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 4:03am UTC](https://discuss.elastic.co/t/terms-facet-getting-all-the-results/4607/10 "2017-07-06T04:03:39Z")

</div>


