# Facets based on object properties instead of string array

**URL:** <https://discuss.elastic.co/t/facets-based-on-object-properties-instead-of-string-array/4473>\
**Category:** Elasticsearch\
**Created:** [May 25, 2011, 12:18pm UTC](https://discuss.elastic.co/t/facets-based-on-object-properties-instead-of-string-array/4473 "2011-05-25T12:18:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yannick\_Smits\_2](https://avatars.discourse-cdn.com/v4/letter/y/a4c791/32.png) [@Yannick\_Smits\_2](https://discuss.elastic.co/u/Yannick_Smits_2)\
**Post date:** [May 25, 2011, 12:18pm UTC](https://discuss.elastic.co/t/facets-based-on-object-properties-instead-of-string-array/4473/1 "2011-05-25T12:18:38Z")

</div>

Ok so we can do a facets search based on multiple string terms attached to a  
document using an array as explained here  
[http://www.elasticsearch.org/guide/reference/api/search/facets/index.html](http://www.elasticsearch.org/guide/reference/api/search/facets/index.html)  
with the tags example.

Now can we achieve the same if our field is not a string array but a more  
complex object like:

```
           "categories":{

              "type":"object",

              "properties":{

                 "name":{

                    "type" : "string",

                    "index":"not_analyzed"

                 },

                 "content" : { 

                    "type" : "string" 

                 }

              }

           }

```

In this mapping example I would like to do a facet for the categories.name  
when there would possibly be multiple categories per document in this  
structure.

Thanks,

Yannick

---

<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:** [May 25, 2011, 5:39pm UTC](https://discuss.elastic.co/t/facets-based-on-object-properties-instead-of-string-array/4473/2 "2011-05-25T17:39:24Z")

</div>

Yes.  
On Wednesday, May 25, 2011 at 3:18 PM, Yannick Smits wrote:

> Ok so we can do a facets search based on multiple string terms attached to a document using an array as explained here with the tags example.  
> Now can we achieve the same if our field is not a string array but a more complex object like:  
> "categories":{  
> "type":"object",  
> "properties":{  
> "name":{  
> "type" : "string",  
> "index":"not\_analyzed"  
> },  
> "content" : {  
> "type" : "string"  
> }  
> }  
> }  
> In this mapping example I would like to do a facet for the categories.name when there would possibly be multiple categories per document in this structure.
> 
> Thanks,  
> Yannick

---

<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, 4:05am UTC](https://discuss.elastic.co/t/facets-based-on-object-properties-instead-of-string-array/4473/3 "2017-07-06T04:05:20Z")

</div>


