# Highlight values from one field in another field

**URL:** https://discuss.elastic.co/t/highlight-values-from-one-field-in-another-field/15064
**Category:** Elasticsearch
**Created:** [December 31, 2013, 2:40pm UTC](https://discuss.elastic.co/t/highlight-values-from-one-field-in-another-field/15064 "2013-12-31T14:40:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Maya](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Maya](https://discuss.elastic.co/u/Maya)
#### Post date: [December 31, 2013, 2:40pm UTC](https://discuss.elastic.co/t/highlight-values-from-one-field-in-another-field/15064/1 "2013-12-31T14:40:21Z")

</div>

Hi All,

We have multi value field - "name". We would like to highlight those values  
in anther field - "text". For example, for the values:  
"name" : ["name1", "name2", "name3", "name4"]  
"text" : "name1 is a friend of name2"

we would like to get the result:  
highlight: {  
text : [_name1_ is a friend of _name2_]  
}

Is it possible to reach that in a single query?

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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a717c411-3d9f-432d-97d3-713cef5d378e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a717c411-3d9f-432d-97d3-713cef5d378e%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)
#### Post date: [December 31, 2013, 2:42pm UTC](https://discuss.elastic.co/t/highlight-values-from-one-field-in-another-field/15064/2 "2013-12-31T14:42:20Z")

</div>

You mean you want the terms highlighted in one field to come from the  
contents of another field rather than the query? If so, then Elasticsearch  
doesn't support that already but you could write a custom highlighter to do  
that.

Nik

On Tue, Dec 31, 2013 at 9:40 AM, mayap [maya.pollack@gmail.com](mailto:maya.pollack@gmail.com) wrote:

> Hi All,
> 
> We have multi value field - "name". We would like to highlight those  
> values in anther field - "text". For example, for the values:  
> "name" : ["name1", "name2", "name3", "name4"]  
> "text" : "name1 is a friend of name2"
> 
> we would like to get the result:  
> highlight: {  
> text : [_name1_ is a friend of _name2_]  
> }
> 
> Is it possible to reach that in a single query?
> 
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/a717c411-3d9f-432d-97d3-713cef5d378e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a717c411-3d9f-432d-97d3-713cef5d378e%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd3m-VF\_sV6Dv3vf77vgR4R5At8nxYDdF7PLN3tP1\_0byw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd3m-VF_sV6Dv3vf77vgR4R5At8nxYDdF7PLN3tP1_0byw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Maya](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Maya](https://discuss.elastic.co/u/Maya)
#### Post date: [December 31, 2013, 4:28pm UTC](https://discuss.elastic.co/t/highlight-values-from-one-field-in-another-field/15064/3 "2013-12-31T16:28:26Z")

</div>

Thanks for your reply.

I have another question:  
Is it possible in highlight\_query (I'm using version 0.90.9) to use few  
highlight tags? For example I want to highlight "text" field with   
for one sub query and with for another sub query?

On Tuesday, December 31, 2013 4:42:20 PM UTC+2, Nikolas Everett wrote:

> You mean you want the terms highlighted in one field to come from the  
> contents of another field rather than the query? If so, then Elasticsearch  
> doesn't support that already but you could write a custom highlighter to do  
> that.
> 
> Nik
> 
> On Tue, Dec 31, 2013 at 9:40 AM, mayap \<[maya.p...@gmail.com](mailto:maya.p...@gmail.com) \<javascript:\>\>wrote:
> 
> > Hi All,
> > 
> > We have multi value field - "name". We would like to highlight those  
> > values in anther field - "text". For example, for the values:  
> > "name" : ["name1", "name2", "name3", "name4"]  
> > "text" : "name1 is a friend of name2"
> > 
> > we would like to get the result:  
> > highlight: {  
> > text : [_name1_ is a friend of _name2_]  
> > }
> > 
> > Is it possible to reach that in a single query?
> > 
> > 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:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/a717c411-3d9f-432d-97d3-713cef5d378e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a717c411-3d9f-432d-97d3-713cef5d378e%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/443130dc-9a82-45d0-a3a9-866ddb9bd5e3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/443130dc-9a82-45d0-a3a9-866ddb9bd5e3%40googlegroups.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, 1:58am UTC](https://discuss.elastic.co/t/highlight-values-from-one-field-in-another-field/15064/4 "2017-07-06T01:58:55Z")

</div>


