# Highlight not working in Query\_String for some content

**URL:** <https://discuss.elastic.co/t/highlight-not-working-in-query-string-for-some-content/4639>\
**Category:** Elasticsearch\
**Created:** [June 16, 2011, 12:56pm UTC](https://discuss.elastic.co/t/highlight-not-working-in-query-string-for-some-content/4639 "2011-06-16T12:56:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![senthil\_prabhu](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@senthil\_prabhu](https://discuss.elastic.co/u/senthil_prabhu)\
**Post date:** [June 16, 2011, 12:56pm UTC](https://discuss.elastic.co/t/highlight-not-working-in-query-string-for-some-content/4639/1 "2011-06-16T12:56:43Z")

</div>

Hi all,

Highlight not working for the below query (query\_string)

{ "query\_string" : {"query" : "\_text:"Rasheed Wallace tied a season  
high with 25 points and had"","default\_operator" : "OR","analyzer" :  
"standard","allow\_leading\_wildcard" :  
true,"lowercase\_expanded\_terms" : true,"enable\_position\_increments" :  
true,"fuzzy\_prefix\_length" : 0,"fuzzy\_min\_sim" : 0.5,"phrase\_slop" :  
0,"boost" : 1.0 } }

but the same query working for the phrase "Rasheed Wallace tied"

{ "query\_string" : {"query" : "\_text:"Rasheed Wallace tied  
"","default\_operator" : "OR","analyzer" :  
"standard","allow\_leading\_wildcard" :  
true,"lowercase\_expanded\_terms" : true,"enable\_position\_increments" :  
true,"fuzzy\_prefix\_length" : 0,"fuzzy\_min\_sim" : 0.5,"phrase\_slop" :  
0,"boost" : 1.0 } }

How to solve this issue...?

I want to highlight the searched content whatever it is.... Is there  
any possibilites...?

---

<div class="post-metadata">

**Author:** ![ofavre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ofavre/32/116819_2.png) [@ofavre](https://discuss.elastic.co/u/ofavre)\
**Post date:** [July 13, 2011, 3:57pm UTC](https://discuss.elastic.co/t/highlight-not-working-in-query-string-for-some-content/4639/2 "2011-07-13T15:57:57Z")

</div>

I think it comes from the phrase query.  
A query string with a quoted content won't work, a text\_phrase query won't  
either.

I guess it has to do with the following file:  
modules/elasticsearch/src/main/java/org/apache/lucene/search/vectorhighlight/CustomFieldQuery.java  
in the flatten() function.

--  
Olivier Favre

[www.yakaz.com](http://www.yakaz.com)

2011/6/16 senthil prabhu [senthilsebi@gmail.com](mailto:senthilsebi@gmail.com)

> Hi all,
> 
> Highlight not working for the below query (query\_string)
> 
> { "query\_string" : {"query" : "\_text:"Rasheed Wallace tied a season  
> high with 25 points and had"","default\_operator" : "OR","analyzer" :  
> "standard","allow\_leading\_wildcard" :  
> true,"lowercase\_expanded\_terms" : true,"enable\_position\_increments" :  
> true,"fuzzy\_prefix\_length" : 0,"fuzzy\_min\_sim" : 0.5,"phrase\_slop" :  
> 0,"boost" : 1.0 } }
> 
> but the same query working for the phrase "Rasheed Wallace tied"
> 
> { "query\_string" : {"query" : "\_text:"Rasheed Wallace tied  
> "","default\_operator" : "OR","analyzer" :  
> "standard","allow\_leading\_wildcard" :  
> true,"lowercase\_expanded\_terms" : true,"enable\_position\_increments" :  
> true,"fuzzy\_prefix\_length" : 0,"fuzzy\_min\_sim" : 0.5,"phrase\_slop" :  
> 0,"boost" : 1.0 } }
> 
> How to solve this issue...?
> 
> I want to highlight the searched content whatever it is.... Is there  
> any possibilites...?

---

<div class="post-metadata">

**Author:** ![Nicolas\_Lalevee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicolas_lalevee/32/2892_2.png) [@Nicolas\_Lalevee](https://discuss.elastic.co/u/Nicolas_Lalevee)\
**Post date:** [July 15, 2011, 10:37am UTC](https://discuss.elastic.co/t/highlight-not-working-in-query-string-for-some-content/4639/3 "2011-07-15T10:37:17Z")

</div>

Le 13 juil. 2011 à 17:57, Olivier Favre a écrit :

> I think it comes from the phrase query.  
> A query string with a quoted content won't work, a text\_phrase query won't either.
> 
> I guess it has to do with the following file:  
> modules/elasticsearch/src/main/java/org/apache/lucene/search/vectorhighlight/CustomFieldQuery.java  
> in the flatten() function.

It has been fixed with my patch:

> <https://github.com/elastic/elasticsearch/pull/1065>
>
> Prefix queries needs to be rewritten so the highlighter can work. So the pull re…quest.
> 
> The highlight of prefix queries doesn't highlight the prefix but the full word. I have written some code on the client side to change the highlighted words. For instance, searching "ski", lucene highlight "\<\>skiing\</\>", "\<\>skin\</\>" or "\<\>skills\</\>". So my code change the highlighted parts to be: "\<\>ski\</\>in", "\<\>ski\</\>n" or "\<\>ski\</\>lls". This code may be interesting to be on the server part, but I don't know where. If you think it is interesting, let me know.

Nicolas

> --  
> Olivier Favre
> 
> [www.yakaz.com](http://www.yakaz.com)
> 
> 2011/6/16 senthil prabhu [senthilsebi@gmail.com](mailto:senthilsebi@gmail.com)  
> Hi all,
> 
> Highlight not working for the below query (query\_string)
> 
> { "query\_string" : {"query" : "\_text:"Rasheed Wallace tied a season  
> high with 25 points and had"","default\_operator" : "OR","analyzer" :  
> "standard","allow\_leading\_wildcard" :  
> true,"lowercase\_expanded\_terms" : true,"enable\_position\_increments" :  
> true,"fuzzy\_prefix\_length" : 0,"fuzzy\_min\_sim" : 0.5,"phrase\_slop" :  
> 0,"boost" : 1.0 } }
> 
> but the same query working for the phrase "Rasheed Wallace tied"
> 
> { "query\_string" : {"query" : "\_text:"Rasheed Wallace tied  
> "","default\_operator" : "OR","analyzer" :  
> "standard","allow\_leading\_wildcard" :  
> true,"lowercase\_expanded\_terms" : true,"enable\_position\_increments" :  
> true,"fuzzy\_prefix\_length" : 0,"fuzzy\_min\_sim" : 0.5,"phrase\_slop" :  
> 0,"boost" : 1.0 } }
> 
> How to solve this issue...?
> 
> I want to highlight the searched content whatever it is.... Is there  
> any possibilites...?

---

<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:00am UTC](https://discuss.elastic.co/t/highlight-not-working-in-query-string-for-some-content/4639/4 "2017-07-06T04:00:32Z")

</div>


