# Highlight based on a field

**URL:** https://discuss.elastic.co/t/highlight-based-on-a-field/10250
**Category:** Elasticsearch
**Created:** [January 7, 2013, 12:06pm UTC](https://discuss.elastic.co/t/highlight-based-on-a-field/10250 "2013-01-07T12:06:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)
#### Post date: [January 7, 2013, 12:06pm UTC](https://discuss.elastic.co/t/highlight-based-on-a-field/10250/1 "2013-01-07T12:06:28Z")

</div>

Hi ,

Following is a sample feed i have.

_Feed - 1_  
{  
"entity" : "YHOO",  
"Content" : "Its a great day at yahoo (YHOO) today"  
}

_Feed - 2_  
{  
"entity" : "GOOG",  
"Content" : "Google(GOOG) is going to launch g+"  
}

Now i want the highlighting output as

"Its a great day at yahoo (_YHOO_) today"  
"Google(_GOOG_) is going to launch g+"

I want to highlight based on the field "entity" rather than a predefined  
like YHOO where the latter will fail to give the output i am looking for.  
Is this possible in elasticsearch ?

Thanks  
Vineeth

--

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [January 8, 2013, 3:33am UTC](https://discuss.elastic.co/t/highlight-based-on-a-field/10250/2 "2013-01-08T03:33:20Z")

</div>

If text that should be highlighted is stored with the record, wouldn't it  
be faster and simpler to highlight text during indexing?

On Monday, January 7, 2013 7:06:28 AM UTC-5, Vineeth Mohan wrote:

> Hi ,
> 
> Following is a sample feed i have.
> 
> _Feed - 1_  
> {  
> "entity" : "YHOO",  
> "Content" : "Its a great day at yahoo (YHOO) today"  
> }
> 
> _Feed - 2_  
> {  
> "entity" : "GOOG",  
> "Content" : "Google(GOOG) is going to launch g+"  
> }
> 
> Now i want the highlighting output as
> 
> "Its a great day at yahoo (_YHOO_) today"  
> "Google(_GOOG_) is going to launch g+"
> 
> I want to highlight based on the field "entity" rather than a predefined  
> like YHOO where the latter will fail to give the output i am looking for.  
> Is this possible in elasticsearch ?
> 
> Thanks  
> Vineeth

--

---

<div class="post-metadata">

### Author: ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)
#### Post date: [January 8, 2013, 3:49am UTC](https://discuss.elastic.co/t/highlight-based-on-a-field/10250/3 "2013-01-08T03:49:20Z")

</div>

That is a good suggetion , let me see where i can reach by that.

Thanks  
Vineeth

On Tue, Jan 8, 2013 at 9:03 AM, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:

> If text that should be highlighted is stored with the record, wouldn't it  
> be faster and simpler to highlight text during indexing?
> 
> On Monday, January 7, 2013 7:06:28 AM UTC-5, Vineeth Mohan wrote:
> 
> > Hi ,
> > 
> > Following is a sample feed i have.
> > 
> > _Feed - 1_  
> > {  
> > "entity" : "YHOO",  
> > "Content" : "Its a great day at yahoo (YHOO) today"  
> > }
> > 
> > _Feed - 2_  
> > {  
> > "entity" : "GOOG",  
> > "Content" : "Google(GOOG) is going to launch g+"  
> > }
> > 
> > Now i want the highlighting output as
> > 
> > "Its a great day at yahoo (_YHOO_) today"  
> > "Google(_GOOG_) is going to launch g+"
> > 
> > I want to highlight based on the field "entity" rather than a predefined  
> > like YHOO where the latter will fail to give the output i am looking for.  
> > Is this possible in elasticsearch ?
> > 
> > Thanks  
> > Vineeth
> > 
> > --

--

---

<div class="post-metadata">

### Author: ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)
#### Post date: [January 8, 2013, 3:52am UTC](https://discuss.elastic.co/t/highlight-based-on-a-field/10250/4 "2013-01-08T03:52:57Z")

</div>

oops forgot to tell a important point.

Say i am tagging all the stuff i need to highlight while indexing , how am  
i supposed to get the highlighted text while searching.  
I will have to write a highlighter for myself by taking the entire source.

Thanks  
Vineeth

On Tue, Jan 8, 2013 at 9:19 AM, Vineeth Mohan [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)wrote:

> That is a good suggetion , let me see where i can reach by that.
> 
> Thanks  
> Vineeth
> 
> On Tue, Jan 8, 2013 at 9:03 AM, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:
> 
> > If text that should be highlighted is stored with the record, wouldn't it  
> > be faster and simpler to highlight text during indexing?
> > 
> > On Monday, January 7, 2013 7:06:28 AM UTC-5, Vineeth Mohan wrote:
> > 
> > > Hi ,
> > > 
> > > Following is a sample feed i have.
> > > 
> > > _Feed - 1_  
> > > {  
> > > "entity" : "YHOO",  
> > > "Content" : "Its a great day at yahoo (YHOO) today"  
> > > }
> > > 
> > > _Feed - 2_  
> > > {  
> > > "entity" : "GOOG",  
> > > "Content" : "Google(GOOG) is going to launch g+"  
> > > }
> > > 
> > > Now i want the highlighting output as
> > > 
> > > "Its a great day at yahoo (_YHOO_) today"  
> > > "Google(_GOOG_) is going to launch g+"
> > > 
> > > I want to highlight based on the field "entity" rather than a predefined  
> > > like YHOO where the latter will fail to give the output i am looking for.  
> > > Is this possible in elasticsearch ?
> > > 
> > > Thanks  
> > > Vineeth
> > > 
> > > --

--

---

<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:57am UTC](https://discuss.elastic.co/t/highlight-based-on-a-field/10250/5 "2017-07-06T02:57:27Z")

</div>


