# Best practice for showing different text on a terms facet

**URL:** <https://discuss.elastic.co/t/best-practice-for-showing-different-text-on-a-terms-facet/4826>\
**Category:** Elasticsearch\
**Created:** [July 9, 2011, 2:44pm UTC](https://discuss.elastic.co/t/best-practice-for-showing-different-text-on-a-terms-facet/4826 "2011-07-09T14:44:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raul\_Jr\_Martinez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raul_jr_martinez/32/1286_2.png) [@Raul\_Jr\_Martinez](https://discuss.elastic.co/u/Raul_Jr_Martinez)\
**Post date:** [July 9, 2011, 2:44pm UTC](https://discuss.elastic.co/t/best-practice-for-showing-different-text-on-a-terms-facet/4826/1 "2011-07-09T14:44:32Z")

</div>

Hello,

Just wondering how the following requirements can be accomplished  
using ElasticSearch (if there's such an option).

I have several sets of documents that contains the following fields:

doc 1:  
username --\> user123  
author --\> John Doe  
content --\> This is a test message

doc 2:  
username --\> user112  
author --\> John Doe Jr.  
content --\> This is a test message from junior

I want to be able to display a navigation based on terms facet like  
(links):

John Doe (1)  
John Doe Jr (1)

The "John Doe (1)" link is based on the following sample html anchor

The "John Doe Jr (1)" link is based on the following sample html  
anchor

Can this be done using a single term facet query?

---

<div class="post-metadata">

**Author:** ![Wojciech\_Durczynski](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wojciech\_Durczynski](https://discuss.elastic.co/u/Wojciech_Durczynski)\
**Post date:** [July 11, 2011, 8:34am UTC](https://discuss.elastic.co/t/best-practice-for-showing-different-text-on-a-terms-facet/4826/2 "2011-07-11T08:34:15Z")

</div>

It wonders me too.  
I have one field with document's internal name and second with  
"caption" - translation to show.  
I'd like to do filtering on internal name but show facet values taken  
from caption field.  
It'd be great to have terms facet, that returns aggregated data from  
these two fields (facet values as pairs of internal name and caption).

On Jul 9, 4:44 pm, rmartinez [jun...@gmail.com](mailto:jun...@gmail.com) wrote:

> Hello,
> 
> Just wondering how the following requirements can be accomplished  
> using Elasticsearch (if there's such an option).
> 
> I have several sets of documents that contains the following fields:
> 
> doc 1:  
> username --\> user123  
> author --\> John Doe  
> content --\> This is a test message
> 
> doc 2:  
> username --\> user112  
> author --\> John Doe Jr.  
> content --\> This is a test message from junior
> 
> I want to be able to display a navigation based on terms facet like  
> (links):
> 
> John Doe (1)  
> John Doe Jr (1)
> 
> The "John Doe (1)" link is based on the following sample html anchor
> 
> The "John Doe Jr (1)" link is based on the following sample html  
> anchor
> 
> Can this be done using a single term facet query?

---

<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:** [July 11, 2011, 5:08pm UTC](https://discuss.elastic.co/t/best-practice-for-showing-different-text-on-a-terms-facet/4826/3 "2011-07-11T17:08:10Z")

</div>

In this case, why not do a simple search on the author name and get back the doc itself, without using terms facet? The text phrase prefix query might fit here.

On Monday, July 11, 2011 at 11:34 AM, Wojciech Durczyński wrote:

> It wonders me too.  
> I have one field with document's internal name and second with  
> "caption" - translation to show.  
> I'd like to do filtering on internal name but show facet values taken  
> from caption field.  
> It'd be great to have terms facet, that returns aggregated data from  
> these two fields (facet values as pairs of internal name and caption).
> 
> On Jul 9, 4:44 pm, rmartinez \<[jun...@gmail.com](mailto:jun...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> 
> > Hello,
> > 
> > Just wondering how the following requirements can be accomplished  
> > using Elasticsearch (if there's such an option).
> > 
> > I have several sets of documents that contains the following fields:
> > 
> > doc 1:  
> > username --\> user123  
> > author --\> John Doe  
> > content --\> This is a test message
> > 
> > doc 2:  
> > username --\> user112  
> > author --\> John Doe Jr.  
> > content --\> This is a test message from junior
> > 
> > I want to be able to display a navigation based on terms facet like  
> > (links):
> > 
> > John Doe (1)  
> > John Doe Jr (1)
> > 
> > The "John Doe (1)" link is based on the following sample html anchor
> > 
> > The "John Doe Jr (1)" link is based on the following sample html  
> > anchor
> > 
> > Can this be done using a single term facet query?

---

<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:01am UTC](https://discuss.elastic.co/t/best-practice-for-showing-different-text-on-a-terms-facet/4826/4 "2017-07-06T04:01:00Z")

</div>


