# Term Faceting in Date Buckets (ala Date Histogram)

**URL:** https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206
**Category:** Elasticsearch
**Created:** [October 2, 2012, 1:32am UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206 "2012-10-02T01:32:32Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Anthony\_D](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Anthony\_D](https://discuss.elastic.co/u/Anthony_D)
#### Post date: [October 2, 2012, 1:32am UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206/1 "2012-10-02T01:32:32Z")

</div>

Hey ES gurus -  
I'm trying to write an ElasticSearch query which in effect amounts to a  
combination of a traditional term facet and a date histogram facet. I  
thought that the date histogram facet may be exactly what I need here, but  
from what I can tell it only seems to work on numeric field types,  
providing statistical (or scripted) analysis on the values of the field in  
question. While there's hack-ish ways around this, I'm hoping that there's  
still a way to get what I'm going for using the built in functionality  
which would typically also be the most efficient way to solve this problem.

Instead of doing statistical analysis on a numeric field with the date  
histogram facet, I just need a count of the top(n) terms, bucketed by date  
interval. Can this be done using existing functionality, is this  
functionality planned, or does anybody have any suggestions on the most  
efficient way to go about this particular problem?

Thanks greatly -  
~Anthony

--

---

<div class="post-metadata">

### Author: ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)
#### Post date: [October 2, 2012, 5:19am UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206/2 "2012-10-02T05:19:27Z")

</div>

Hi Anthony,

This is not possible with standard ElasticSearch. We needed a similar thing on my work and I wrote a plugin to add a facet type that allows combining date histograms with any other facet. It is still work in progress but it works. You can check it out on [https://github.com/bleskes/elasticfacets](https://github.com/bleskes/elasticfacets)

Cheers,  
Boaz

--

---

<div class="post-metadata">

### Author: ![Anthony\_D](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Anthony\_D](https://discuss.elastic.co/u/Anthony_D)
#### Post date: [October 2, 2012, 6:06am UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206/3 "2012-10-02T06:06:17Z")

</div>

Boaz -  
Thanks a ton! I'll see how this fits in and send you back any updates or  
feedback. 🙂

~Anthony

On Monday, October 1, 2012 10:19:27 PM UTC-7, Boaz Leskes wrote:

> Hi Anthony,
> 
> This is not possible with standard Elasticsearch. We needed a similar  
> thing on my work and I wrote a plugin to add a facet type that allows  
> combining date histograms with any other facet. It is still work in  
> progress but it works. You can check it out on  
> [GitHub - bleskes/elasticfacets: A set of facets and related tools for ElasticSearch](https://github.com/bleskes/elasticfacets)
> 
> Cheers,  
> Boaz

--

---

<div class="post-metadata">

### Author: ![chenryn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chenryn/32/44917_2.png) [@chenryn](https://discuss.elastic.co/u/chenryn)
#### Post date: [October 2, 2012, 9:46am UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206/4 "2012-10-02T09:46:13Z")

</div>

I try to install plugin in my cluster and curl the example json but get 'No  
facet type found for [faceted\_date\_histogram]'. Should I do anything else  
before using search?

2012/10/2 Boaz Leskes [b.leskes@gmail.com](mailto:b.leskes@gmail.com)

> Hi Anthony,
> 
> This is not possible with standard Elasticsearch. We needed a similar  
> thing on my work and I wrote a plugin to add a facet type that allows  
> combining date histograms with any other facet. It is still work in  
> progress but it works. You can check it out on  
> [GitHub - bleskes/elasticfacets: A set of facets and related tools for ElasticSearch](https://github.com/bleskes/elasticfacets)
> 
> Cheers,  
> Boaz
> 
> --

--

---

<div class="post-metadata">

### Author: ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)
#### Post date: [October 2, 2012, 11:44am UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206/5 "2012-10-02T11:44:42Z")

</div>

Other then restarting the ES cluster I don't think so. The plugin should  
log when it is loaded:

logger.info("ElasticFacets plugin initialized");

Do you see that in the log file?

Just to be sure - you are using ES version 0.19.8 or higher?

On Tuesday, October 2, 2012 11:46:16 AM UTC+2, chenlin rao wrote:

> I try to install plugin in my cluster and curl the example json but get  
> 'No facet type found for [faceted\_date\_histogram]'. Should I do anything  
> else before using search?
> 
> 2012/10/2 Boaz Leskes \<[b.le...@gmail.com](mailto:b.le...@gmail.com) \<javascript:\>\>
> 
> > Hi Anthony,
> > 
> > This is not possible with standard Elasticsearch. We needed a similar  
> > thing on my work and I wrote a plugin to add a facet type that allows  
> > combining date histograms with any other facet. It is still work in  
> > progress but it works. You can check it out on  
> > [GitHub - bleskes/elasticfacets: A set of facets and related tools for ElasticSearch](https://github.com/bleskes/elasticfacets)
> > 
> > Cheers,  
> > Boaz
> > 
> > --

--

---

<div class="post-metadata">

### Author: ![chenryn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chenryn/32/44917_2.png) [@chenryn](https://discuss.elastic.co/u/chenryn)
#### Post date: [October 2, 2012, 2:07pm UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206/6 "2012-10-02T14:07:01Z")

</div>

Yes, ES version 0.19.8. And I see log like  
"[2012-10-02 17:30:02,263][INFO][plugins] [Quasar II]  
loaded [river-rabbitmq], sites [head, elasticfacets]  
[2012-10-02 17:30:05,552][INFO][node] [Quasar II]  
{0.19.8}[31031]: initialized  
[2012-10-02 17:30:05,552][INFO][node] [Quasar II]  
{0.19.8}[31031]: starting ...  
"

2012/10/2 Boaz Leskes [b.leskes@gmail.com](mailto:b.leskes@gmail.com)

> Other then restarting the ES cluster I don't think so. The plugin should  
> log when it is loaded:
> 
> logger.info("ElasticFacets plugin initialized");
> 
> Do you see that in the log file?
> 
> Just to be sure - you are using ES version 0.19.8 or higher?
> 
> On Tuesday, October 2, 2012 11:46:16 AM UTC+2, chenlin rao wrote:
> 
> > I try to install plugin in my cluster and curl the example json but get  
> > 'No facet type found for [faceted\_date\_histogram]'. Should I do anything  
> > else before using search?
> > 
> > 2012/10/2 Boaz Leskes [b.le...@gmail.com](mailto:b.le...@gmail.com)
> > 
> > Hi Anthony,
> > 
> > > This is not possible with standard Elasticsearch. We needed a similar  
> > > thing on my work and I wrote a plugin to add a facet type that allows  
> > > combining date histograms with any other facet. It is still work in  
> > > progress but it works. You can check it out on  
> > > [https://github.com/bleskes/\*\*elasticfacets](https://github.com/bleskes/**elasticfacets)[https://github.com/bleskes/elasticfacets](https://github.com/bleskes/elasticfacets)
> > > 
> > > Cheers,  
> > > Boaz
> > > 
> > > --
> > 
> > --

--

---

<div class="post-metadata">

### Author: ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)
#### Post date: [October 2, 2012, 3:28pm UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206/7 "2012-10-02T15:28:25Z")

</div>

I see the problem. It thinks elasticfacets is a site plugin (thus html and  
not java). I also see that I only have binaries ready for version 0.19.9  
(version we have in production). I'll try to compile asap but I can't do it  
tonight. Is there any chance you can upgrade?

On Tuesday, October 2, 2012 4:07:03 PM UTC+2, chenlin rao wrote:

> Yes, ES version 0.19.8. And I see log like  
> "[2012-10-02 17:30:02,263][INFO][plugins] [Quasar II]  
> loaded [river-rabbitmq], sites [head, elasticfacets]  
> [2012-10-02 17:30:05,552][INFO][node] [Quasar II]  
> {0.19.8}[31031]: initialized  
> [2012-10-02 17:30:05,552][INFO][node] [Quasar II]  
> {0.19.8}[31031]: starting ...  
> "
> 
> 2012/10/2 Boaz Leskes \<[b.le...@gmail.com](mailto:b.le...@gmail.com) \<javascript:\>\>
> 
> > Other then restarting the ES cluster I don't think so. The plugin should  
> > log when it is loaded:
> > 
> > logger.info("ElasticFacets plugin initialized");
> > 
> > Do you see that in the log file?
> > 
> > Just to be sure - you are using ES version 0.19.8 or higher?
> > 
> > On Tuesday, October 2, 2012 11:46:16 AM UTC+2, chenlin rao wrote:
> > 
> > > I try to install plugin in my cluster and curl the example json but get  
> > > 'No facet type found for [faceted\_date\_histogram]'. Should I do anything  
> > > else before using search?
> > > 
> > > 2012/10/2 Boaz Leskes [b.le...@gmail.com](mailto:b.le...@gmail.com)
> > > 
> > > Hi Anthony,
> > > 
> > > > This is not possible with standard Elasticsearch. We needed a similar  
> > > > thing on my work and I wrote a plugin to add a facet type that allows  
> > > > combining date histograms with any other facet. It is still work in  
> > > > progress but it works. You can check it out on  
> > > > [https://github.com/bleskes/\*\*elasticfacets](https://github.com/bleskes/**elasticfacets)[https://github.com/bleskes/elasticfacets](https://github.com/bleskes/elasticfacets)
> > > > 
> > > > Cheers,  
> > > > Boaz
> > > > 
> > > > --
> > > 
> > > --

--

---

<div class="post-metadata">

### Author: ![chenryn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chenryn/32/44917_2.png) [@chenryn](https://discuss.elastic.co/u/chenryn)
#### Post date: [October 2, 2012, 3:59pm UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206/8 "2012-10-02T15:59:43Z")

</div>

ok, I will try to upgrade ~tks

2012/10/2 Boaz Leskes [b.leskes@gmail.com](mailto:b.leskes@gmail.com)

> I see the problem. It thinks elasticfacets is a site plugin (thus html and  
> not java). I also see that I only have binaries ready for version 0.19.9  
> (version we have in production). I'll try to compile asap but I can't do it  
> tonight. Is there any chance you can upgrade?
> 
> On Tuesday, October 2, 2012 4:07:03 PM UTC+2, chenlin rao wrote:
> 
> > Yes, ES version 0.19.8. And I see log like  
> > "[2012-10-02 17:30:02,263][INFO][plugins] [Quasar II]  
> > loaded [river-rabbitmq], sites [head, elasticfacets]  
> > [2012-10-02 17:30:05,552][INFO][node] [Quasar II]  
> > {0.19.8}[31031]: initialized  
> > [2012-10-02 17:30:05,552][INFO][node] [Quasar II]  
> > {0.19.8}[31031]: starting ...  
> > "
> > 
> > 2012/10/2 Boaz Leskes [b.le...@gmail.com](mailto:b.le...@gmail.com)
> > 
> > Other then restarting the ES cluster I don't think so. The plugin should
> > 
> > > log when it is loaded:
> > > 
> > > logger.info("ElasticFacets plugin initialized");
> > > 
> > > Do you see that in the log file?
> > > 
> > > Just to be sure - you are using ES version 0.19.8 or higher?
> > > 
> > > On Tuesday, October 2, 2012 11:46:16 AM UTC+2, chenlin rao wrote:
> > > 
> > > > I try to install plugin in my cluster and curl the example json but get  
> > > > 'No facet type found for [faceted\_date\_histogram]'. Should I do anything  
> > > > else before using search?
> > > > 
> > > > 2012/10/2 Boaz Leskes [b.le...@gmail.com](mailto:b.le...@gmail.com)
> > > > 
> > > > Hi Anthony,
> > > > 
> > > > > This is not possible with standard Elasticsearch. We needed a similar  
> > > > > thing on my work and I wrote a plugin to add a facet type that allows  
> > > > > combining date histograms with any other facet. It is still work in  
> > > > > progress but it works. You can check it out on  
> > > > > [https://github.com/bleskes/\*\*ela\*\*sticfacets](https://github.com/bleskes/ **ela** sticfacets)[https://github.com/bleskes/elasticfacets](https://github.com/bleskes/elasticfacets)
> > > > > 
> > > > > Cheers,  
> > > > > Boaz
> > > > > 
> > > > > --
> > > > 
> > > > --
> > 
> > --

--

---

<div class="post-metadata">

### Author: ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)
#### Post date: [October 5, 2012, 9:17am UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206/9 "2012-10-05T09:17:00Z")

</div>

Hi Cehnlin (and Anthony),

I've repackaged the plugin with a version for 0.19.8 as well. If you still  
run 0.19.8, you can install it using bin/plugin -install  
bleskes/elasticfacets/0.1 . Please let me know if it worked out for you.

Cheers,  
Boaz

On Tuesday, October 2, 2012 5:59:46 PM UTC+2, chenlin rao wrote:

> ok, I will try to upgrade ~tks
> 
> 2012/10/2 Boaz Leskes \<[b.le...@gmail.com](mailto:b.le...@gmail.com) \<javascript:\>\>
> 
> > I see the problem. It thinks elasticfacets is a site plugin (thus html  
> > and not java). I also see that I only have binaries ready for version  
> > 0.19.9 (version we have in production). I'll try to compile asap but I  
> > can't do it tonight. Is there any chance you can upgrade?
> > 
> > On Tuesday, October 2, 2012 4:07:03 PM UTC+2, chenlin rao wrote:
> > 
> > > Yes, ES version 0.19.8. And I see log like  
> > > "[2012-10-02 17:30:02,263][INFO][plugins] [Quasar II]  
> > > loaded [river-rabbitmq], sites [head, elasticfacets]  
> > > [2012-10-02 17:30:05,552][INFO][node] [Quasar II]  
> > > {0.19.8}[31031]: initialized  
> > > [2012-10-02 17:30:05,552][INFO][node] [Quasar II]  
> > > {0.19.8}[31031]: starting ...  
> > > "
> > > 
> > > 2012/10/2 Boaz Leskes [b.le...@gmail.com](mailto:b.le...@gmail.com)
> > > 
> > > Other then restarting the ES cluster I don't think so. The plugin should
> > > 
> > > > log when it is loaded:
> > > > 
> > > > logger.info("ElasticFacets plugin initialized");
> > > > 
> > > > Do you see that in the log file?
> > > > 
> > > > Just to be sure - you are using ES version 0.19.8 or higher?
> > > > 
> > > > On Tuesday, October 2, 2012 11:46:16 AM UTC+2, chenlin rao wrote:
> > > > 
> > > > > I try to install plugin in my cluster and curl the example json but  
> > > > > get 'No facet type found for [faceted\_date\_histogram]'. Should I do  
> > > > > anything else before using search?
> > > > > 
> > > > > 2012/10/2 Boaz Leskes [b.le...@gmail.com](mailto:b.le...@gmail.com)
> > > > > 
> > > > > Hi Anthony,
> > > > > 
> > > > > > This is not possible with standard Elasticsearch. We needed a similar  
> > > > > > thing on my work and I wrote a plugin to add a facet type that allows  
> > > > > > combining date histograms with any other facet. It is still work in  
> > > > > > progress but it works. You can check it out on  
> > > > > > [https://github.com/bleskes/\*\*ela\*\*sticfacets](https://github.com/bleskes/ **ela** sticfacets)[https://github.com/bleskes/elasticfacets](https://github.com/bleskes/elasticfacets)
> > > > > > 
> > > > > > Cheers,  
> > > > > > Boaz
> > > > > > 
> > > > > > --
> > > > > 
> > > > > --
> > > 
> > > --

--

---

<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:09am UTC](https://discuss.elastic.co/t/term-faceting-in-date-buckets-ala-date-histogram/9206/10 "2017-07-06T03:09:59Z")

</div>


