# Highlighting bug?

**URL:** <https://discuss.elastic.co/t/highlighting-bug/9382>\
**Category:** Elasticsearch\
**Created:** [October 16, 2012, 3:29pm UTC](https://discuss.elastic.co/t/highlighting-bug/9382 "2012-10-16T15:29:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wires](https://avatars.discourse-cdn.com/v4/letter/w/f4b2a3/32.png) [@wires](https://discuss.elastic.co/u/wires)\
**Post date:** [October 16, 2012, 3:29pm UTC](https://discuss.elastic.co/t/highlighting-bug/9382/1 "2012-10-16T15:29:34Z")

</div>

A query wrapped in a "constant\_score" inside a "should" of a "bool" doesn't  
highlight. inside a "must" it does and without the "constant\_score" it does  
too. Is this intentional or a bug? If it's intentional, what is the  
reasoning behind it...?

Here is a gist demonstrating this: [https://gist.github.com/3899939](https://gist.github.com/3899939)

grtz,  
Jelle

--

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [October 16, 2012, 9:26pm UTC](https://discuss.elastic.co/t/highlighting-bug/9382/2 "2012-10-16T21:26:19Z")

</div>

hey,

On Tuesday, October 16, 2012 5:29:34 PM UTC+2, wires wrote:

> A query wrapped in a "constant\_score" inside a "should" of a "bool"  
> doesn't highlight. inside a "must" it does and without the "constant\_score"  
> it does too. Is this intentional or a bug? If it's intentional, what is the  
> reasoning behind it...?

I think this is a "limitation" / "bug" in ES. The lucene highlighter  
doesn't support this at all out of the box and the ES highlighter only  
supports the must case since it optimizes the boolean query if it only has  
a single clause. can you create an issue for this problem on github?

simon

> Here is a gist demonstrating this: [Elastic search strange highlighting behaviour · GitHub](https://gist.github.com/3899939)
> 
> grtz,  
> Jelle

--

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [October 17, 2012, 7:58am UTC](https://discuss.elastic.co/t/highlighting-bug/9382/3 "2012-10-17T07:58:52Z")

</div>

FYI - I created an issue in Lucene land and provided a fix for this.  
([[LUCENE-4486] Highlighter doesn't support ConstantScoreQuery - ASF JIRA](https://issues.apache.org/jira/browse/LUCENE-4486)). The elasticsearch  
issue is here: [Highlighting fails for ConstantScoreQuery · Issue #2332 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2332) I  
will provide a PR soon so this should work in upcoming releases. Thanks for  
reporting this!

simon

On Tuesday, October 16, 2012 11:26:20 PM UTC+2, simonw wrote:

> hey,
> 
> On Tuesday, October 16, 2012 5:29:34 PM UTC+2, wires wrote:
> 
> > A query wrapped in a "constant\_score" inside a "should" of a "bool"  
> > doesn't highlight. inside a "must" it does and without the "constant\_score"  
> > it does too. Is this intentional or a bug? If it's intentional, what is the  
> > reasoning behind it...?
> 
> I think this is a "limitation" / "bug" in ES. The lucene highlighter  
> doesn't support this at all out of the box and the ES highlighter only  
> supports the must case since it optimizes the boolean query if it only has  
> a single clause. can you create an issue for this problem on github?
> 
> simon
> 
> > Here is a gist demonstrating this: [Elastic search strange highlighting behaviour · GitHub](https://gist.github.com/3899939)
> > 
> > grtz,  
> > Jelle

--

---

<div class="post-metadata">

**Author:** ![wires](https://avatars.discourse-cdn.com/v4/letter/w/f4b2a3/32.png) [@wires](https://discuss.elastic.co/u/wires)\
**Post date:** [October 18, 2012, 8:22am UTC](https://discuss.elastic.co/t/highlighting-bug/9382/4 "2012-10-18T08:22:19Z")

</div>

Op woensdag 17 oktober 2012 09:58:52 UTC+2 schreef simonw het volgende:

> FYI - I created an issue in Lucene land and provided a fix for this. (  
> [[LUCENE-4486] Highlighter doesn't support ConstantScoreQuery - ASF JIRA](https://issues.apache.org/jira/browse/LUCENE-4486)). The elasticsearch  
> issue is here: [Highlighting fails for ConstantScoreQuery · Issue #2332 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2332) I  
> will provide a PR soon so this should work in upcoming releases. Thanks for  
> reporting this!

Thanks! No problem, my collegue Ernst Bunders ran into this, I just  
reported it and wrote the test.

Grtz,  
Jelle.

--

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [October 21, 2012, 9:37am UTC](https://discuss.elastic.co/t/highlighting-bug/9382/5 "2012-10-21T09:37:59Z")

</div>

FYI- this is fixed and will be in the next release!

On Thursday, October 18, 2012 10:22:19 AM UTC+2, wires wrote:

> Op woensdag 17 oktober 2012 09:58:52 UTC+2 schreef simonw het volgende:
> 
> > FYI - I created an issue in Lucene land and provided a fix for this. (  
> > [[LUCENE-4486] Highlighter doesn't support ConstantScoreQuery - ASF JIRA](https://issues.apache.org/jira/browse/LUCENE-4486)). The elasticsearch  
> > issue is here: [Highlighting fails for ConstantScoreQuery · Issue #2332 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2332) I  
> > will provide a PR soon so this should work in upcoming releases. Thanks for  
> > reporting this!
> 
> Thanks! No problem, my collegue Ernst Bunders ran into this, I just  
> reported it and wrote the test.
> 
> Grtz,  
> Jelle.

--

---

<div class="post-metadata">

**Author:** ![wires](https://avatars.discourse-cdn.com/v4/letter/w/f4b2a3/32.png) [@wires](https://discuss.elastic.co/u/wires)\
**Post date:** [October 22, 2012, 1:52pm UTC](https://discuss.elastic.co/t/highlighting-bug/9382/6 "2012-10-22T13:52:12Z")

</div>

Op zondag 21 oktober 2012 11:38:00 UTC+2 schreef simonw het volgende:

> FYI- this is fixed and will be in the next release!

awesome, thanks

--

---

<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, 3:07am UTC](https://discuss.elastic.co/t/highlighting-bug/9382/7 "2017-07-06T03:07:35Z")

</div>


