# Multiple facets in a single request

**URL:** <https://discuss.elastic.co/t/multiple-facets-in-a-single-request/8093>\
**Category:** Elasticsearch\
**Created:** [June 13, 2012, 9:52pm UTC](https://discuss.elastic.co/t/multiple-facets-in-a-single-request/8093 "2012-06-13T21:52:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pat\_Christopher\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pat_christopher_2/32/2434_2.png) [@Pat\_Christopher\_2](https://discuss.elastic.co/u/Pat_Christopher_2)\
**Post date:** [June 13, 2012, 9:52pm UTC](https://discuss.elastic.co/t/multiple-facets-in-a-single-request/8093/1 "2012-06-13T21:52:06Z")

</div>

Hola,  
I'm attempting to issue several facet requests in a single query. I  
thought I could do something like so:

{  
"query": {  
"query\_string": {  
"query": "things"  
}  
},  
"facets": [  
{  
"time1": {  
"terms": {  
"field": "a thang"  
},  
"facet\_filter": {  
"numeric\_range": {  
"event\_timestamp": {  
"gte": 1339188071000,  
"lte": 1339188076000  
}  
}  
}  
}  
},  
{  
"time2": {  
"terms": {  
"field": "a thing"  
},  
"facet\_filter": {  
"numeric\_range": {  
"event\_timestamp": {  
"gte": 1339188071000,  
"lte": 1339188076000  
}  
}  
}  
}  
}  
]  
}

I thought that 'facets' could operate over a list of named facet requests.  
But when I do that I receive the following error:

Parse Failure [No facet type found for [time1]]

So it seems that elasticsearch is reading the name of the facet as the  
type. I'm running 0.18.5. If this is a fixed/known issue, my bad. But,  
is that the correct syntax? I was unable to find any examples in the docs  
or on the newsgroup.

Thanks,  
Pat

---

<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, 2012, 4:44am UTC](https://discuss.elastic.co/t/multiple-facets-in-a-single-request/8093/2 "2012-06-14T04:44:56Z")

</div>

I think that "A thing" can not be the name of a field.

David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 13 juin 2012 à 23:52, Pat Christopher [coffeepac@gmail.com](mailto:coffeepac@gmail.com) a écrit :

> Hola,  
> I'm attempting to issue several facet requests in a single query. I thought I could do something like so:
> 
> {  
> "query": {  
> "query\_string": {  
> "query": "things"  
> }  
> },  
> "facets": [  
> {  
> "time1": {  
> "terms": {  
> "field": "a thang"  
> },  
> "facet\_filter": {  
> "numeric\_range": {  
> "event\_timestamp": {  
> "gte": 1339188071000,  
> "lte": 1339188076000  
> }  
> }  
> }  
> }  
> },  
> {  
> "time2": {  
> "terms": {  
> "field": "a thing"  
> },  
> "facet\_filter": {  
> "numeric\_range": {  
> "event\_timestamp": {  
> "gte": 1339188071000,  
> "lte": 1339188076000  
> }  
> }  
> }  
> }  
> }  
> ]  
> }
> 
> I thought that 'facets' could operate over a list of named facet requests. But when I do that I receive the following error:
> 
> Parse Failure [No facet type found for [time1]]
> 
> So it seems that elasticsearch is reading the name of the facet as the type. I'm running 0.18.5. If this is a fixed/known issue, my bad. But, is that the correct syntax? I was unable to find any examples in the docs or on the newsgroup.
> 
> Thanks,  
> Pat

---

<div class="post-metadata">

**Author:** ![Pierre\_Durand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pierre_durand/32/1895_2.png) [@Pierre\_Durand](https://discuss.elastic.co/u/Pierre_Durand)\
**Post date:** [June 14, 2012, 9:54am UTC](https://discuss.elastic.co/t/multiple-facets-in-a-single-request/8093/3 "2012-06-14T09:54:23Z")

</div>

This is the correct syntax for facets:

"facets": {  
"level": {  
"terms": {  
"field": "level"  
}  
},  
"color": {  
"nested": "balls",  
"terms": {  
"field": "color"  
}  
},  
"size": {  
"nested": "balls",  
"terms": {  
"field": "size"  
}  
}  
}

On Wednesday, June 13, 2012 11:52:06 PM UTC+2, Pat Christopher wrote:

> Hola,  
> I'm attempting to issue several facet requests in a single query. I  
> thought I could do something like so:
> 
> {  
> "query": {  
> "query\_string": {  
> "query": "things"  
> }  
> },  
> "facets": [  
> {  
> "time1": {  
> "terms": {  
> "field": "a thang"  
> },  
> "facet\_filter": {  
> "numeric\_range": {  
> "event\_timestamp": {  
> "gte": 1339188071000,  
> "lte": 1339188076000  
> }  
> }  
> }  
> }  
> },  
> {  
> "time2": {  
> "terms": {  
> "field": "a thing"  
> },  
> "facet\_filter": {  
> "numeric\_range": {  
> "event\_timestamp": {  
> "gte": 1339188071000,  
> "lte": 1339188076000  
> }  
> }  
> }  
> }  
> }  
> ]  
> }
> 
> I thought that 'facets' could operate over a list of named facet requests.  
> But when I do that I receive the following error:
> 
> Parse Failure [No facet type found for [time1]]
> 
> So it seems that elasticsearch is reading the name of the facet as the  
> type. I'm running 0.18.5. If this is a fixed/known issue, my bad. But,  
> is that the correct syntax? I was unable to find any examples in the docs  
> or on the newsgroup.
> 
> Thanks,  
> Pat

---

<div class="post-metadata">

**Author:** ![Pat\_Christopher\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pat_christopher_2/32/2434_2.png) [@Pat\_Christopher\_2](https://discuss.elastic.co/u/Pat_Christopher_2)\
**Post date:** [June 14, 2012, 8:30pm UTC](https://discuss.elastic.co/t/multiple-facets-in-a-single-request/8093/4 "2012-06-14T20:30:43Z")

</div>

And it is! Thanks Pierre!

On Thursday, June 14, 2012 2:54:23 AM UTC-7, Pierre Durand wrote:

> This is the correct syntax for facets:
> 
> "facets": {  
> "level": {  
> "terms": {  
> "field": "level"  
> }  
> },  
> "color": {  
> "nested": "balls",  
> "terms": {  
> "field": "color"  
> }  
> },  
> "size": {  
> "nested": "balls",  
> "terms": {  
> "field": "size"  
> }  
> }  
> }
> 
> On Wednesday, June 13, 2012 11:52:06 PM UTC+2, Pat Christopher wrote:
> 
> > Hola,  
> > I'm attempting to issue several facet requests in a single query. I  
> > thought I could do something like so:
> > 
> > {  
> > "query": {  
> > "query\_string": {  
> > "query": "things"  
> > }  
> > },  
> > "facets": [  
> > {  
> > "time1": {  
> > "terms": {  
> > "field": "a thang"  
> > },  
> > "facet\_filter": {  
> > "numeric\_range": {  
> > "event\_timestamp": {  
> > "gte": 1339188071000,  
> > "lte": 1339188076000  
> > }  
> > }  
> > }  
> > }  
> > },  
> > {  
> > "time2": {  
> > "terms": {  
> > "field": "a thing"  
> > },  
> > "facet\_filter": {  
> > "numeric\_range": {  
> > "event\_timestamp": {  
> > "gte": 1339188071000,  
> > "lte": 1339188076000  
> > }  
> > }  
> > }  
> > }  
> > }  
> > ]  
> > }
> > 
> > I thought that 'facets' could operate over a list of named facet  
> > requests. But when I do that I receive the following error:
> > 
> > Parse Failure [No facet type found for [time1]]
> > 
> > So it seems that elasticsearch is reading the name of the facet as the  
> > type. I'm running 0.18.5. If this is a fixed/known issue, my bad. But,  
> > is that the correct syntax? I was unable to find any examples in the docs  
> > or on the newsgroup.
> > 
> > Thanks,  
> > Pat

---

<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:24am UTC](https://discuss.elastic.co/t/multiple-facets-in-a-single-request/8093/5 "2017-07-06T03:24:10Z")

</div>


