# Combined Facets? Terms + Histogram

**URL:** <https://discuss.elastic.co/t/combined-facets-terms-histogram/5455>\
**Category:** Elasticsearch\
**Created:** [September 26, 2011, 4:33pm UTC](https://discuss.elastic.co/t/combined-facets-terms-histogram/5455 "2011-09-26T16:33:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rio/32/2728_2.png) [@Rio](https://discuss.elastic.co/u/Rio)\
**Post date:** [September 26, 2011, 4:33pm UTC](https://discuss.elastic.co/t/combined-facets-terms-histogram/5455/1 "2011-09-26T16:33:06Z")

</div>

Hi,

Devs: Thanks for all the hard work. Elasticsearch is awesome!

Question: I'm still getting to know ElasticSearch, but I'm wondering  
if there is a way to combine a histogram facet with a terms facet in a  
single result set. For example, I have articles with created\_at and  
states of ['draft', 'pending\_review', 'rejected', 'published',  
'etc']. I'm trying return counts of articles per state for each date  
for a data visualization. I'd be looking for an output that might look  
like this:

[  
{  
"time": 1307577600000,  
[  
{  
"term": "draft",  
"count": 10  
},  
{  
"term": "published",  
"count": 3  
}  
]  
},  
{  
"time": :1307404800000,  
[  
{  
"term": "draft",  
"count": 6  
},  
{  
"term": "published",  
"count": 13  
}  
]  
}{  
...moretimes...  
}  
]

Is there anyway to fetch this in a single query? I was looking around  
the documents and couldn't find a way to implement it. Any help would  
be appreciated!

-Mario

---

<div class="post-metadata">

**Author:** ![Rio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rio/32/2728_2.png) [@Rio](https://discuss.elastic.co/u/Rio)\
**Post date:** [September 27, 2011, 8:08pm UTC](https://discuss.elastic.co/t/combined-facets-terms-histogram/5455/2 "2011-09-27T20:08:23Z")

</div>

Any thoughts or suggestions, any one?

On Sep 26, 12:33 pm, Rio [rio...@gmail.com](mailto:rio...@gmail.com) wrote:

> Hi,
> 
> Devs: Thanks for all the hard work. Elasticsearch is awesome!
> 
> Question: I'm still getting to know Elasticsearch, but I'm wondering  
> if there is a way to combine a histogram facet with a terms facet in a  
> single result set. For example, I have articles with created\_at and  
> states of ['draft', 'pending\_review', 'rejected', 'published',  
> 'etc']. I'm trying return counts of articles per state for each date  
> for a data visualization. I'd be looking for an output that might look  
> like this:
> 
> [  
> {  
> "time": 1307577600000,  
> [  
> {  
> "term": "draft",  
> "count": 10  
> },  
> {  
> "term": "published",  
> "count": 3  
> }  
> ]  
> },  
> {  
> "time": :1307404800000,  
> [  
> {  
> "term": "draft",  
> "count": 6  
> },  
> {  
> "term": "published",  
> "count": 13  
> }  
> ]  
> }{  
> ...moretimes...  
> }  
> ]
> 
> Is there anyway to fetch this in a single query? I was looking around  
> the documents and couldn't find a way to implement it. Any help would  
> be appreciated!
> 
> -Mario

---

<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:** [September 27, 2011, 9:30pm UTC](https://discuss.elastic.co/t/combined-facets-terms-histogram/5455/3 "2011-09-27T21:30:29Z")

</div>

No, there isn't a way to do that currently.

On Tue, Sep 27, 2011 at 11:08 PM, Rio [rio517@gmail.com](mailto:rio517@gmail.com) wrote:

> Any thoughts or suggestions, any one?
> 
> On Sep 26, 12:33 pm, Rio [rio...@gmail.com](mailto:rio...@gmail.com) wrote:
> 
> > Hi,
> > 
> > Devs: Thanks for all the hard work. Elasticsearch is awesome!
> > 
> > Question: I'm still getting to know Elasticsearch, but I'm wondering  
> > if there is a way to combine a histogram facet with a terms facet in a  
> > single result set. For example, I have articles with created\_at and  
> > states of ['draft', 'pending\_review', 'rejected', 'published',  
> > 'etc']. I'm trying return counts of articles per state for each date  
> > for a data visualization. I'd be looking for an output that might look  
> > like this:
> > 
> > [  
> > {  
> > "time": 1307577600000,  
> > [  
> > {  
> > "term": "draft",  
> > "count": 10  
> > },  
> > {  
> > "term": "published",  
> > "count": 3  
> > }  
> > ]  
> > },  
> > {  
> > "time": :1307404800000,  
> > [  
> > {  
> > "term": "draft",  
> > "count": 6  
> > },  
> > {  
> > "term": "published",  
> > "count": 13  
> > }  
> > ]  
> > }{  
> > ...moretimes...  
> > }  
> > ]
> > 
> > Is there anyway to fetch this in a single query? I was looking around  
> > the documents and couldn't find a way to implement it. Any help would  
> > be appreciated!
> > 
> > -Mario

---

<div class="post-metadata">

**Author:** ![Rio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rio/32/2728_2.png) [@Rio](https://discuss.elastic.co/u/Rio)\
**Post date:** [September 28, 2011, 7:14am UTC](https://discuss.elastic.co/t/combined-facets-terms-histogram/5455/4 "2011-09-28T07:14:20Z")

</div>

Cool. Thanks!

---

<div class="post-metadata">

**Author:** ![Arun\_Ramakrishnan](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@Arun\_Ramakrishnan](https://discuss.elastic.co/u/Arun_Ramakrishnan)\
**Post date:** [November 25, 2011, 7:05am UTC](https://discuss.elastic.co/t/combined-facets-terms-histogram/5455/5 "2011-11-25T07:05:10Z")

</div>

Hi,  
I am just starting out with elasticsearch and I really like it. Very helpful and rich with features!

I've been using elasticsearch to index events. Similarly I want to query for a count of documents by time. That is, I want to be able to see an average of the number of error events per hour for the last week etc.

Any idea if this sort of feature might be coming up?

Thanks!

---

<div class="post-metadata">

**Author:** ![Brad\_Jordan](https://avatars.discourse-cdn.com/v4/letter/b/4bbf92/32.png) [@Brad\_Jordan](https://discuss.elastic.co/u/Brad_Jordan)\
**Post date:** [April 29, 2013, 5:31pm UTC](https://discuss.elastic.co/t/combined-facets-terms-histogram/5455/6 "2013-04-29T17:31:41Z")

</div>

This looks like an old post is there a way to do this now?

---

<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, 2:39am UTC](https://discuss.elastic.co/t/combined-facets-terms-histogram/5455/7 "2017-07-06T02:39:13Z")

</div>


