# Combining facet values

**URL:** <https://discuss.elastic.co/t/combining-facet-values/4431>\
**Category:** Elasticsearch\
**Created:** [May 18, 2011, 12:31pm UTC](https://discuss.elastic.co/t/combining-facet-values/4431 "2011-05-18T12:31:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jasper\_van\_Wanrooy\_C](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasper_van_wanrooy_c/32/2494_2.png) [@Jasper\_van\_Wanrooy\_C](https://discuss.elastic.co/u/Jasper_van_Wanrooy_C)\
**Post date:** [May 18, 2011, 12:31pm UTC](https://discuss.elastic.co/t/combining-facet-values/4431/1 "2011-05-18T12:31:19Z")

</div>

Hi,

I'm creating a search functionality for a portal with products. Each product belongs to a single category. A category consists of a name, a normalized name and an id. How can I create a facet, which returns the three different fields?  
I already tried to create three specific facets and combine them. However, this doesn't work out for the category id with the sorting.

The category mapping is defined as follows:  
'category' =\> array(  
'properties' =\> array(  
'id' =\> array(  
'type' =\> 'multi\_field',  
'fields' =\> array(  
'id' =\> array('type' =\> 'long'),  
'stringified' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
)  
),  
'name' =\> array(  
'type' =\> 'multi\_field',  
'fields' =\> array(  
'name' =\> array('type' =\> 'string', 'index' =\> 'analyzed', 'boost' =\> 2),  
'untouched' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
)  
),  
'name\_normalized' =\> array('type' =\> 'string', 'not\_analyzed', 'boost' =\> 2),  
'foreign\_reference' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed'),  
'path' =\> array(  
'type' =\> 'multi\_field',  
'fields' =\> array(  
'path' =\> array('type' =\> 'string', 'index' =\> 'analyzed', 'index\_analyzer' =\> 'path\_index\_analyzer', 'search\_analyzer' =\> 'path\_search\_analyzer'),  
'untouched' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
)  
),  
'path\_normalized' =\> array(  
'type' =\> 'multi\_field',  
'fields' =\> array(  
'path\_normalized' =\> array('type' =\> 'string', 'index' =\> 'analyzed', 'index\_analyzer' =\> 'path\_index\_analyzer', 'search\_analyzer' =\> 'path\_search\_analyzer'),  
'untouched' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
)  
)  
)  
)

Thanks in advance!

Thanks, Jasper

---

<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 19, 2011, 11:35am UTC](https://discuss.elastic.co/t/combining-facet-values/4431/2 "2011-05-19T11:35:25Z")

</div>

Term facet only works on a single field.  
On Wednesday, May 18, 2011 at 3:31 PM, Jasper van Wanrooy - Chatventure wrote:

> Hi,
> 
> I'm creating a search functionality for a portal with products. Each product belongs to a single category. A category consists of a name, a normalized name and an id. How can I create a facet, which returns the three different fields?  
> I already tried to create three specific facets and combine them. However, this doesn't work out for the category id with the sorting.
> 
> The category mapping is defined as follows:  
> 'category' =\> array(  
> 'properties' =\> array(  
> 'id' =\> array(  
> 'type' =\> 'multi\_field',  
> 'fields' =\> array(  
> 'id' =\> array('type' =\> 'long'),  
> 'stringified' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
> )  
> ),  
> 'name' =\> array(  
> 'type' =\> 'multi\_field',  
> 'fields' =\> array(  
> 'name' =\> array('type' =\> 'string', 'index' =\> 'analyzed', 'boost' =\> 2),  
> 'untouched' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
> )  
> ),  
> 'name\_normalized' =\> array('type' =\> 'string', 'not\_analyzed', 'boost' =\> 2),  
> 'foreign\_reference' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed'),  
> 'path' =\> array(  
> 'type' =\> 'multi\_field',  
> 'fields' =\> array(  
> 'path' =\> array('type' =\> 'string', 'index' =\> 'analyzed', 'index\_analyzer' =\> 'path\_index\_analyzer', 'search\_analyzer' =\> 'path\_search\_analyzer'),  
> 'untouched' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
> )  
> ),  
> 'path\_normalized' =\> array(  
> 'type' D\> 'multi\_field',  
> 'fields' =\> array(  
> 'path\_normalized' =\> array('type' =\> 'string', 'index' =\> 'analyzed', 'index\_analyzer' =\> 'path\_index\_analyzer', 'search\_analyzer' =\> 'path\_search\_analyzer'),  
> 'untouched' D\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
> )  
> )  
> )  
> )
> 
> Thanks in advance!
> 
> Thanks, Jasper

---

<div class="post-metadata">

**Author:** ![Jasper\_van\_Wanrooy\_C](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasper_van_wanrooy_c/32/2494_2.png) [@Jasper\_van\_Wanrooy\_C](https://discuss.elastic.co/u/Jasper_van_Wanrooy_C)\
**Post date:** [May 19, 2011, 10:46pm UTC](https://discuss.elastic.co/t/combining-facet-values/4431/3 "2011-05-19T22:46:39Z")

</div>

Thanks for your reply. I fixed the problem by combining the values with a script on the terms facet. Not ideal, but it works for me.

On donderdag 19 mei 2011 at 13:35, Shay Banon wrote:

> Term facet only works on a single field.  
> On Wednesday, May 18, 2011 at 3:31 PM, Jasper van Wanrooy - Chatventure wrote:
> 
> > Hi,
> > 
> > I'm creating a search functionality for a portal with products. Each product belongs to a single category. A category consists of a name, a normalized name and an id. How can I create a facet, which returns the three different fields?  
> > I already tried to create three specific facets and combine them. However, this doesn't work out for the category id with the sorting.
> > 
> > The category mapping is defined as follows:  
> > 'category' =\> array(  
> > 'properties' =\> array(  
> > 'id' D\> array(  
> > 'type' =\> 'multi\_field',  
> > 'fields' =\> array(  
> > 'id' =\> array('type' =\> 'long'),  
> > 'stringified' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
> > )  
> > ),  
> > 'name' =\> array(  
> > 'type' =\> 'multi\_field',  
> > 'fields' =\> array(  
> > 'name' =\> array('type' =\> 'string', 'index' =\> 'analyzed', 'boost' =\> 2),  
> > 'untouched' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
> > )  
> > ),  
> > 'name\_normalized' =\> array('type' =\> 'string', 'not\_analyzed', 'boost' =\> 2),  
> > 'foreign\_reference' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed'),  
> > 'path' =\> array(  
> > 'type' =\> 'multi\_field',  
> > 'fields' =\> array(  
> > 'path' =\> array('type' =\> 'string', 'index' =\> 'analyzed', 'index\_analyzer' =\> 'path\_index\_analyzer', 'search\_analyzer' =\> 'path\_search\_analyzer'),  
> > 'untouched' =\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
> > )  
> > ),  
> > 'path\_normalized' =\> array(  
> > 'type' D\> 'multi\_field',  
> > 'fields' =\> array(  
> > 'path\_normalized' =\> array('type' =\> 'string', 'index' =\> 'analyzed', 'index\_analyzer' =\> 'path\_index\_analyzer', 'search\_analyzer' =\> 'path\_search\_analyzer'),  
> > 'untouched' D\> array('type' =\> 'string', 'index' =\> 'not\_analyzed')  
> > )  
> > )  
> > )  
> > )
> > 
> > Thanks in advance!
> > 
> > Thanks, Jasper

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [May 20, 2011, 7:42pm UTC](https://discuss.elastic.co/t/combining-facet-values/4431/4 "2011-05-20T19:42:11Z")

</div>

BTW: If you hit performance problems for your approach you could  
combine them into one field while indexing

---

<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/combining-facet-values/4431/5 "2017-07-06T04:05:45Z")

</div>

Closed on July 6, 2017, 4:05am UTC


