# Bug in Highlighting

**URL:** <https://discuss.elastic.co/t/bug-in-highlighting/3954>\
**Category:** Elasticsearch\
**Created:** [February 21, 2011, 1:29pm UTC](https://discuss.elastic.co/t/bug-in-highlighting/3954 "2011-02-21T13:29:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![resetdel](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@resetdel](https://discuss.elastic.co/u/resetdel)\
**Post date:** [February 21, 2011, 1:29pm UTC](https://discuss.elastic.co/t/bug-in-highlighting/3954/1 "2011-02-21T13:29:00Z")

</div>

Hi

I'm use latest version of ES(0.15) and had some problems with  
highlighting.  
Data :  
{  
...  
streamType: Feed  
message: bla bla bla post bla bla 1 bla  
tenantId: 1  
...  
}

Example of query:  
query : { bool : {must : [  
{field: {streamType: {query: "Feed"}}},  
{wildcard : { message : "_post_" }}, {term : { tenantId :  
"1" }}, {range : {postDate : {...}}} ]}},  
highlight : {"  
"pre\_tags" : ...  
"post\_tags" : ...  
"fields" : {"message" : {"fragment\_size" : 200,  
"number\_of\_fragments" : 1}" } }

Result:  
bla bla bla post bla bla \<Highlighting

> 1 bla

As you can see in highlight fields only "message" marked as  
highlighted, but in results some items highlighted for field tenantId.

Any ideas how to resolve this?

Thanks.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 21, 2011, 1:41pm UTC](https://discuss.elastic.co/t/bug-in-highlighting/3954/2 "2011-02-21T13:41:58Z")

</div>

Hi

> I'm use latest version of ES(0.15) and had some problems with  
> highlighting.

Please could you gist a curl recreation of the problem - it's easier  
than reading it in an email.

See [Elastic Stack and Solutions Help · Forums and Slack | Elastic](http://www.elasticsearch.com/help) for an explanation

thanks

clint

---

<div class="post-metadata">

**Author:** ![resetdel](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@resetdel](https://discuss.elastic.co/u/resetdel)\
**Post date:** [February 21, 2011, 2:30pm UTC](https://discuss.elastic.co/t/bug-in-highlighting/3954/3 "2011-02-21T14:30:53Z")

</div>

sample [ES: demo for highlight bug · GitHub](https://gist.github.com/837120)

On Feb 21, 3:41 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:

> Hi
> 
> > I'm use latest version of ES(0.15) and had some problems with  
> > highlighting.
> 
> Please could you gist a curl recreation of the problem - it's easier  
> than reading it in an email.
> 
> Seehttp://www.elasticsearch.com/helpfor an explanation
> 
> thanks
> 
> clint

---

<div class="post-metadata">

**Author:** ![resetdel](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@resetdel](https://discuss.elastic.co/u/resetdel)\
**Post date:** [February 21, 2011, 2:37pm UTC](https://discuss.elastic.co/t/bug-in-highlighting/3954/4 "2011-02-21T14:37:15Z")

</div>

here: [https://gist.github.com/837120](https://gist.github.com/837120)

On Feb 21, 3:41 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:

> Hi
> 
> > I'm use latest version of ES(0.15) and had some problems with  
> > highlighting.
> 
> Please could you gist a curl recreation of the problem - it's easier  
> than reading it in an email.
> 
> Seehttp://www.elasticsearch.com/helpfor an explanation
> 
> thanks
> 
> clint

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 21, 2011, 2:55pm UTC](https://discuss.elastic.co/t/bug-in-highlighting/3954/5 "2011-02-21T14:55:10Z")

</div>

On Mon, 2011-02-21 at 06:37 -0800, resetdel wrote:

> here: [https://gist.github.com/837120](https://gist.github.com/837120)

I haven't used highlighting before, so I'm not sure if this is a bug or  
not.

It looks to me like the '1' is being highlighted because you specify  
{tenantId: 1} as part of the query, when actually you want it to be  
applied as a filter.

I've posted a version using a query of type 'filtered' which highlights  
correctly: [ES: demo for highlight bug · GitHub](https://gist.github.com/837120#comments)

clint

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 21, 2011, 3:32pm UTC](https://discuss.elastic.co/t/bug-in-highlighting/3954/6 "2011-02-21T15:32:56Z")

</div>

Hi resetdel

> > It looks to me like the '1' is being highlighted because you specify  
> > {tenantId: 1} as part of the query, when actually you want it to be  
> > applied as a filter.

> ```
> Yes i'm think so(because tenantId part of query).
> 
> I am not sure that filter will be good for me, because there
> can be more than 100 000 hits (even more than 1000 000 hits),
> and apply filter to this operation will be less productive than
> query.
> 
> ```

On the contrary, you definitely want to use filters - they are faster  
than queries because ES doesn't have to calculate the scores.

Filters are very fast indeed

clint

---

<div class="post-metadata">

**Author:** ![resetdel](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@resetdel](https://discuss.elastic.co/u/resetdel)\
**Post date:** [February 21, 2011, 6:49pm UTC](https://discuss.elastic.co/t/bug-in-highlighting/3954/7 "2011-02-21T18:49:08Z")

</div>

A lot of thanks

On Feb 21, 5:32 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:

> Hi resetdel
> 
> > > It looks to me like the '1' is being highlighted because you specify  
> > > {tenantId: 1} as part of the query, when actually you want it to be  
> > > applied as a filter.  
> > > Yes i'm think so(because tenantId part of query).
> 
> > ```
> > I am not sure that filter will be good for me, because there
> > can be more than 100 000 hits (even more than 1000 000 hits),
> > and apply filter to this operation will be less productive than
> > query.
> > 
> > ```
> 
> On the contrary, you definitely want to use filters - they are faster  
> than queries because ES doesn't have to calculate the scores.
> 
> Filters are very fast indeed
> 
> clint

---

<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:11am UTC](https://discuss.elastic.co/t/bug-in-highlighting/3954/8 "2017-07-06T04:11:45Z")

</div>


