# Facets with Nested and string in same request

**URL:** <https://discuss.elastic.co/t/facets-with-nested-and-string-in-same-request/12106>\
**Category:** Elasticsearch\
**Created:** [May 24, 2013, 2:18am UTC](https://discuss.elastic.co/t/facets-with-nested-and-string-in-same-request/12106 "2013-05-24T02:18:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anderson\_Bento](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anderson_bento/32/2288_2.png) [@Anderson\_Bento](https://discuss.elastic.co/u/Anderson_Bento)\
**Post date:** [May 24, 2013, 2:18am UTC](https://discuss.elastic.co/t/facets-with-nested-and-string-in-same-request/12106/1 "2013-05-24T02:18:27Z")

</div>

Hi elasticers, how are u? 🙂

Can I request two facets (a string and a field of a nested field) in the  
same request?

example of my facet request:

{  
"query": {  
"match": {  
"product\_name": {  
"query": "red t-shirt",  
"operator": "and",  
"analyzer": "default",  
"fuzziness": null,  
"lenient": true,  
"max\_expansions": 100,  
"minimum\_should\_match": 2,  
"prefix\_length": 2,  
"type": null  
}  
}  
},  
"facets": {  
"Mark": {  
"terms": {  
"fields": [  
"mark\_name"  
],  
"order": "count",  
"all\_terms": false,  
"size": null,  
"exclude": null,  
"regex": null,  
"regex\_flags": null,  
"script": null,  
"script\_field": "\_source.mark\_name",  
"params": null,  
"lang": null  
},  
"facet\_filter": null  
},  
"Products": {  
"terms": {  
"fields": [  
"product\_name"  
],  
"order": "count",  
"all\_terms": false,  
"size": null,  
"exclude": null,  
"regex": null,  
"regex\_flags": null,  
"script": null,  
"script\_field": "\_source.product\_name",  
"params": null,  
"lang": null  
},  
"facet\_filter": null  
},  
"Colors": {  
"terms\_stats": {  
"fields": null,  
"order": "total",  
"all\_TermsStats": null,  
"size": null,  
"exclude": null,  
"regex": null,  
"regex\_flags": null,  
"key\_field": "color",  
"value\_field": "count",  
"key\_script": null,  
"value\_script": null,  
"params": null,  
"lang": null  
},  
"facet\_filter": null  
}  
}  
}

to me, it's return a Java Exception:  
_Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException: failed  
to find mappings for [count]_

thanks!!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 24, 2013, 10:34am UTC](https://discuss.elastic.co/t/facets-with-nested-and-string-in-same-request/12106/2 "2013-05-24T10:34:45Z")

</div>

Hi Anderson

Do you mean "nested" or an inner object? They are different. A nested  
object has type `nested`, as opposed to type `object`.

If you DO mean "nested", then you have to specify that you want a nested  
facet [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/)

Not sure how ES will play with all of those null values 🙂

clint

On 24 May 2013 04:18, Anderson Bento [deca.rox@gmail.com](mailto:deca.rox@gmail.com) wrote:

> Hi elasticers, how are u? 🙂
> 
> Can I request two facets (a string and a field of a nested field) in the  
> same request?
> 
> example of my facet request:
> 
> {  
> "query": {  
> "match": {  
> "product\_name": {  
> "query": "red t-shirt",  
> "operator": "and",  
> "analyzer": "default",  
> "fuzziness": null,  
> "lenient": true,  
> "max\_expansions": 100,  
> "minimum\_should\_match": 2,  
> "prefix\_length": 2,  
> "type": null  
> }  
> }  
> },  
> "facets": {  
> "Mark": {  
> "terms": {  
> "fields": [  
> "mark\_name"  
> ],  
> "order": "count",  
> "all\_terms": false,  
> "size": null,  
> "exclude": null,  
> "regex": null,  
> "regex\_flags": null,  
> "script": null,  
> "script\_field": "\_source.mark\_name",  
> "params": null,  
> "lang": null  
> },  
> "facet\_filter": null  
> },  
> "Products": {  
> "terms": {  
> "fields": [  
> "product\_name"  
> ],  
> "order": "count",  
> "all\_terms": false,  
> "size": null,  
> "exclude": null,  
> "regex": null,  
> "regex\_flags": null,  
> "script": null,  
> "script\_field": "\_source.product\_name",  
> "params": null,  
> "lang": null  
> },  
> "facet\_filter": null  
> },  
> "Colors": {  
> "terms\_stats": {  
> "fields": null,  
> "order": "total",  
> "all\_TermsStats": null,  
> "size": null,  
> "exclude": null,  
> "regex": null,  
> "regex\_flags": null,  
> "key\_field": "color",  
> "value\_field": "count",  
> "key\_script": null,  
> "value\_script": null,  
> "params": null,  
> "lang": null  
> },  
> "facet\_filter": null  
> }  
> }  
> }
> 
> to me, it's return a Java Exception:  
> _Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException:  
> failed to find mappings for [count]_
> 
> thanks!!
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Anderson\_Bento](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anderson_bento/32/2288_2.png) [@Anderson\_Bento](https://discuss.elastic.co/u/Anderson_Bento)\
**Post date:** [May 24, 2013, 2:03pm UTC](https://discuss.elastic.co/t/facets-with-nested-and-string-in-same-request/12106/3 "2013-05-24T14:03:34Z")

</div>

yes, I have a nested type.

when I follow the example of api, I get a Exception of java (failed to  
finding maps for [count]

I forget to post the url when i send the jSON:  
curl -XGET [http://localhost:9200/products/\_search\?pretty\=true](http://localhost:9200/products/_search%5C?pretty%5C=true)

Em sexta-feira, 24 de maio de 2013 07h34min45s UTC-3, Clinton Gormley  
escreveu:

> Hi Anderson
> 
> Do you mean "nested" or an inner object? They are different. A nested  
> object has type `nested`, as opposed to type `object`.
> 
> If you DO mean "nested", then you have to specify that you want a nested  
> facet [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/)
> 
> Not sure how ES will play with all of those null values 🙂
> 
> clint
> 
> On 24 May 2013 04:18, Anderson Bento \<[deca...@gmail.com](mailto:deca...@gmail.com) \<javascript:\>\>wrote:
> 
> > Hi elasticers, how are u? 🙂
> > 
> > Can I request two facets (a string and a field of a nested field) in the  
> > same request?
> > 
> > example of my facet request:
> > 
> > {  
> > "query": {  
> > "match": {  
> > "product\_name": {  
> > "query": "red t-shirt",  
> > "operator": "and",  
> > "analyzer": "default",  
> > "fuzziness": null,  
> > "lenient": true,  
> > "max\_expansions": 100,  
> > "minimum\_should\_match": 2,  
> > "prefix\_length": 2,  
> > "type": null  
> > }  
> > }  
> > },  
> > "facets": {  
> > "Mark": {  
> > "terms": {  
> > "fields": [  
> > "mark\_name"  
> > ],  
> > "order": "count",  
> > "all\_terms": false,  
> > "size": null,  
> > "exclude": null,  
> > "regex": null,  
> > "regex\_flags": null,  
> > "script": null,  
> > "script\_field": "\_source.mark\_name",  
> > "params": null,  
> > "lang": null  
> > },  
> > "facet\_filter": null  
> > },  
> > "Products": {  
> > "terms": {  
> > "fields": [  
> > "product\_name"  
> > ],  
> > "order": "count",  
> > "all\_terms": false,  
> > "size": null,  
> > "exclude": null,  
> > "regex": null,  
> > "regex\_flags": null,  
> > "script": null,  
> > "script\_field": "\_source.product\_name",  
> > "params": null,  
> > "lang": null  
> > },  
> > "facet\_filter": null  
> > },  
> > "Colors": {  
> > "terms\_stats": {  
> > "fields": null,  
> > "order": "total",  
> > "all\_TermsStats": null,  
> > "size": null,  
> > "exclude": null,  
> > "regex": null,  
> > "regex\_flags": null,  
> > "key\_field": "color",  
> > "value\_field": "count",  
> > "key\_script": null,  
> > "value\_script": null,  
> > "params": null,  
> > "lang": null  
> > },  
> > "facet\_filter": null  
> > }  
> > }  
> > }
> > 
> > to me, it's return a Java Exception:  
> > _Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException:  
> > failed to find mappings for [count]_
> > 
> > thanks!!
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 25, 2013, 6:23am UTC](https://discuss.elastic.co/t/facets-with-nested-and-string-in-same-request/12106/4 "2013-05-25T06:23:18Z")

</div>

This has nothing to do with the facets. Your URL is messed up:

/products/\_search%5C?pretty%5C=true

You're escaping the ?

But you also have errors in your facet, if you're using nested. You're  
not specifying nested facets

clint

On 24 May 2013 16:03, Anderson Bento [deca.rox@gmail.com](mailto:deca.rox@gmail.com) wrote:

> yes, I have a nested type.
> 
> when I follow the example of api, I get a Exception of java (failed to  
> finding maps for [count]
> 
> I forget to post the url when i send the jSON:  
> curl -XGET [http://localhost:9200/products/\_search\?pretty\=true](http://localhost:9200/products/_search%5C?pretty%5C=true)
> 
> Em sexta-feira, 24 de maio de 2013 07h34min45s UTC-3, Clinton Gormley  
> escreveu:
> 
> > Hi Anderson
> > 
> > Do you mean "nested" or an inner object? They are different. A nested  
> > object has type `nested`, as opposed to type `object`.
> > 
> > If you DO mean "nested", then you have to specify that you want a nested  
> > facet [http://www](http://www).\*\*[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/**reference/api/search/facets/)[http://www.elasticsearch.org/guide/reference/api/search/facets/](http://www.elasticsearch.org/guide/reference/api/search/facets/)
> > 
> > Not sure how ES will play with all of those null values 🙂
> > 
> > clint
> > 
> > On 24 May 2013 04:18, Anderson Bento [deca...@gmail.com](mailto:deca...@gmail.com) wrote:
> > 
> > > Hi elasticers, how are u? 🙂
> > > 
> > > Can I request two facets (a string and a field of a nested field) in the  
> > > same request?
> > > 
> > > example of my facet request:
> > > 
> > > {  
> > > "query": {  
> > > "match": {  
> > > "product\_name": {  
> > > "query": "red t-shirt",  
> > > "operator": "and",  
> > > "analyzer": "default",  
> > > "fuzziness": null,  
> > > "lenient": true,  
> > > "max\_expansions": 100,  
> > > "minimum\_should\_match": 2,  
> > > "prefix\_length": 2,  
> > > "type": null  
> > > }  
> > > }  
> > > },  
> > > "facets": {  
> > > "Mark": {  
> > > "terms": {  
> > > "fields": [  
> > > "mark\_name"  
> > > ],  
> > > "order": "count",  
> > > "all\_terms": false,  
> > > "size": null,  
> > > "exclude": null,  
> > > "regex": null,  
> > > "regex\_flags": null,  
> > > "script": null,  
> > > "script\_field": "\_source.mark\_name",  
> > > "params": null,  
> > > "lang": null  
> > > },  
> > > "facet\_filter": null  
> > > },  
> > > "Products": {  
> > > "terms": {  
> > > "fields": [  
> > > "product\_name"  
> > > ],  
> > > "order": "count",  
> > > "all\_terms": false,  
> > > "size": null,  
> > > "exclude": null,  
> > > "regex": null,  
> > > "regex\_flags": null,  
> > > "script": null,  
> > > "script\_field": "\_source.product\_name",  
> > > "params": null,  
> > > "lang": null  
> > > },  
> > > "facet\_filter": null  
> > > },  
> > > "Colors": {  
> > > "terms\_stats": {  
> > > "fields": null,  
> > > "order": "total",  
> > > "all\_TermsStats": null,  
> > > "size": null,  
> > > "exclude": null,  
> > > "regex": null,  
> > > "regex\_flags": null,  
> > > "key\_field": "color",  
> > > "value\_field": "count",  
> > > "key\_script": null,  
> > > "value\_script": null,  
> > > "params": null,  
> > > "lang": null  
> > > },  
> > > "facet\_filter": null  
> > > }  
> > > }  
> > > }
> > > 
> > > to me, it's return a Java Exception:  
> > > _Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException:  
> > > failed to find mappings for [count]_
> > > 
> > > thanks!!
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:34am UTC](https://discuss.elastic.co/t/facets-with-nested-and-string-in-same-request/12106/5 "2017-07-06T02:34:50Z")

</div>


