# TermFacet REVERSE\_COUNT, above some minCount

**URL:** <https://discuss.elastic.co/t/termfacet-reverse-count-above-some-mincount/5237>\
**Category:** Elasticsearch\
**Created:** [August 24, 2011, 1:59pm UTC](https://discuss.elastic.co/t/termfacet-reverse-count-above-some-mincount/5237 "2011-08-24T13:59:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ridvan\_Gyundogan](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@Ridvan\_Gyundogan](https://discuss.elastic.co/u/Ridvan_Gyundogan)\
**Post date:** [August 24, 2011, 1:59pm UTC](https://discuss.elastic.co/t/termfacet-reverse-count-above-some-mincount/5237/1 "2011-08-24T13:59:12Z")

</div>

Hello All,  
I am experimenting with the TermFacet especially the REVERSE\_COUNT  
ordering.

This gives me at the top terms which are available in 1 document. Can  
I somehow tell Elastic Search to return me terms which are available  
in more than minCount documents?

---

<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:** [August 24, 2011, 6:27pm UTC](https://discuss.elastic.co/t/termfacet-reverse-count-above-some-mincount/5237/2 "2011-08-24T18:27:36Z")

</div>

We can potentially add min count as an additional parameter, but, it will  
need to be applied on the shard level to filter in / out docs computation.

On Wed, Aug 24, 2011 at 4:59 PM, Ridvan Gyundogan [ridvansg@gmail.com](mailto:ridvansg@gmail.com)wrote:

> Hello All,  
> I am experimenting with the TermFacet especially the REVERSE\_COUNT  
> ordering.
> 
> This gives me at the top terms which are available in 1 document. Can  
> I somehow tell Elastic Search to return me terms which are available  
> in more than minCount documents?

---

<div class="post-metadata">

**Author:** ![Ridvan\_Gyundogan](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@Ridvan\_Gyundogan](https://discuss.elastic.co/u/Ridvan_Gyundogan)\
**Post date:** [August 24, 2011, 8:47pm UTC](https://discuss.elastic.co/t/termfacet-reverse-count-above-some-mincount/5237/3 "2011-08-24T20:47:00Z")

</div>

Hi Shay,  
it was not my intention to push this as a feature request. The  
TermFacet is good we are just trying how far we can go with it.

I see that you have the script field and \_index variable not sure  
exactly how they work but is it possible to do something like:

```
        "field" : "tag",
            "size" : 10,
            "script" : "_index>5? true : false"
        }

```

What will be even more interesting for us is to know is it possible  
for a TermFacet ordered by COUNT to specify the maximum percent of  
documents it is contained in.  
For example if I have 100 documents I want to see terms which are  
available in less than 30% of the documents. I suppose this is not  
very easy and I haven't seen this feature anywhere yet.

On Aug 24, 9:27 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> We can potentially add min count as an additional parameter, but, it will  
> need to be applied on the shard level to filter in / out docs computation.
> 
> On Wed, Aug 24, 2011 at 4:59 PM, Ridvan Gyundogan [ridva...@gmail.com](mailto:ridva...@gmail.com)wrote:
> 
> > Hello All,  
> > I am experimenting with the TermFacet especially the REVERSE\_COUNT  
> > ordering.
> 
> > This gives me at the top terms which are available in 1 document. Can  
> > I somehow tell Elastic Search to return me terms which are available  
> > in more than minCount documents?

---

<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:** [August 24, 2011, 10:51pm UTC](https://discuss.elastic.co/t/termfacet-reverse-count-above-some-mincount/5237/4 "2011-08-24T22:51:40Z")

</div>

Where did you see the \_index notion? You can use the script to fetch a field  
value and then check on it, for example: "doc['my\_field'].value \> 5 ? true :  
false".

Anything that has a global state is tricky, 30% of a shard (and assuming  
even distribution of missing terms, it might be ok) might be possible (need  
to think about it).

On Wed, Aug 24, 2011 at 11:47 PM, Ridvan Gyundogan [ridvansg@gmail.com](mailto:ridvansg@gmail.com)wrote:

> Hi Shay,  
> it was not my intention to push this as a feature request. The  
> TermFacet is good we are just trying how far we can go with it.
> 
> I see that you have the script field and \_index variable not sure  
> exactly how they work but is it possible to do something like:
> 
> ```
> "field" : "tag",
> "size" : 10,
> "script" : "_index>5? true : false"
> }
> 
> ```
> 
> What will be even more interesting for us is to know is it possible  
> for a TermFacet ordered by COUNT to specify the maximum percent of  
> documents it is contained in.  
> For example if I have 100 documents I want to see terms which are  
> available in less than 30% of the documents. I suppose this is not  
> very easy and I haven't seen this feature anywhere yet.
> 
> On Aug 24, 9:27 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > We can potentially add min count as an additional parameter, but, it will  
> > need to be applied on the shard level to filter in / out docs  
> > computation.
> > 
> > On Wed, Aug 24, 2011 at 4:59 PM, Ridvan Gyundogan \<[ridva...@gmail.com](mailto:ridva...@gmail.com)  
> > wrote:
> > 
> > > Hello All,  
> > > I am experimenting with the TermFacet especially the REVERSE\_COUNT  
> > > ordering.
> > 
> > > This gives me at the top terms which are available in 1 document. Can  
> > > I somehow tell Elastic Search to return me terms which are available  
> > > in more than minCount documents?

---

<div class="post-metadata">

**Author:** ![Ridvan\_Gyundogan](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@Ridvan\_Gyundogan](https://discuss.elastic.co/u/Ridvan_Gyundogan)\
**Post date:** [August 25, 2011, 6:16am UTC](https://discuss.elastic.co/t/termfacet-reverse-count-above-some-mincount/5237/5 "2011-08-25T06:16:16Z")

</div>

> > Where did you see the \_index notion?  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html)  
> > at the bottom.

On Aug 25, 1:51 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Where did you see the \_index notion? You can use the script to fetch a field  
> value and then check on it, for example: "doc['my\_field'].value \> 5 ? true :  
> false".
> 
> Anything that has a global state is tricky, 30% of a shard (and assuming  
> even distribution of missing terms, it might be ok) might be possible (need  
> to think about it).
> 
> On Wed, Aug 24, 2011 at 11:47 PM, Ridvan Gyundogan [ridva...@gmail.com](mailto:ridva...@gmail.com)wrote:
> 
> > Hi Shay,  
> > it was not my intention to push this as a feature request. The  
> > TermFacet is good we are just trying how far we can go with it.
> 
> > I see that you have the script field and \_index variable not sure  
> > exactly how they work but is it possible to do something like:
> 
> > ```
> > "field" : "tag",
> > "size" : 10,
> > "script" : "_index>5? true : false"
> > }
> > 
> > ```
> 
> > What will be even more interesting for us is to know is it possible  
> > for a TermFacet ordered by COUNT to specify the maximum percent of  
> > documents it is contained in.  
> > For example if I have 100 documents I want to see terms which are  
> > available in less than 30% of the documents. I suppose this is not  
> > very easy and I haven't seen this feature anywhere yet.
> 
> > On Aug 24, 9:27 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > We can potentially add min count as an additional parameter, but, it will  
> > > need to be applied on the shard level to filter in / out docs  
> > > computation.
> 
> > > On Wed, Aug 24, 2011 at 4:59 PM, Ridvan Gyundogan \<[ridva...@gmail.com](mailto:ridva...@gmail.com)  
> > > wrote:
> 
> > > > Hello All,  
> > > > I am experimenting with the TermFacet especially the REVERSE\_COUNT  
> > > > ordering.
> 
> > > > This gives me at the top terms which are available in 1 document. Can  
> > > > I somehow tell Elastic Search to return me terms which are available  
> > > > in more than minCount documents?

---

<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:** [August 26, 2011, 2:23pm UTC](https://discuss.elastic.co/t/termfacet-reverse-count-above-some-mincount/5237/6 "2011-08-26T14:23:41Z")

</div>

Right, that means that you can specify the field name to facet on as \_index,  
which will then simply return counts per index (for multi index search).

On Thu, Aug 25, 2011 at 9:16 AM, Ridvan Gyundogan [ridvansg@gmail.com](mailto:ridvansg@gmail.com)wrote:

> > > Where did you see the \_index notion?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html)  
> at the bottom.
> 
> On Aug 25, 1:51 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > Where did you see the \_index notion? You can use the script to fetch a  
> > field  
> > value and then check on it, for example: "doc['my\_field'].value \> 5 ?  
> > true :  
> > false".
> > 
> > Anything that has a global state is tricky, 30% of a shard (and assuming  
> > even distribution of missing terms, it might be ok) might be possible  
> > (need  
> > to think about it).
> > 
> > On Wed, Aug 24, 2011 at 11:47 PM, Ridvan Gyundogan \<[ridva...@gmail.com](mailto:ridva...@gmail.com)  
> > wrote:
> > 
> > > Hi Shay,  
> > > it was not my intention to push this as a feature request. The  
> > > TermFacet is good we are just trying how far we can go with it.
> > 
> > > I see that you have the script field and \_index variable not sure  
> > > exactly how they work but is it possible to do something like:
> > 
> > > ```
> > > "field" : "tag",
> > > "size" : 10,
> > > "script" : "_index>5? true : false"
> > > }
> > > 
> > > ```
> > 
> > > What will be even more interesting for us is to know is it possible  
> > > for a TermFacet ordered by COUNT to specify the maximum percent of  
> > > documents it is contained in.  
> > > For example if I have 100 documents I want to see terms which are  
> > > available in less than 30% of the documents. I suppose this is not  
> > > very easy and I haven't seen this feature anywhere yet.
> > 
> > > On Aug 24, 9:27 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > > 
> > > > We can potentially add min count as an additional parameter, but, it  
> > > > will  
> > > > need to be applied on the shard level to filter in / out docs  
> > > > computation.
> > 
> > > > On Wed, Aug 24, 2011 at 4:59 PM, Ridvan Gyundogan \<  
> > > > [ridva...@gmail.com](mailto:ridva...@gmail.com)  
> > > > wrote:
> > 
> > > > > Hello All,  
> > > > > I am experimenting with the TermFacet especially the REVERSE\_COUNT  
> > > > > ordering.
> > 
> > > > > This gives me at the top terms which are available in 1 document.  
> > > > > Can  
> > > > > I somehow tell Elastic Search to return me terms which are  
> > > > > available  
> > > > > in more than minCount documents?

---

<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, 3:55am UTC](https://discuss.elastic.co/t/termfacet-reverse-count-above-some-mincount/5237/7 "2017-07-06T03:55:55Z")

</div>


