# Highlighting a text\_phrase\_prefix query

**URL:** <https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094>\
**Category:** Elasticsearch\
**Created:** [August 9, 2011, 4:24am UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094 "2011-08-09T04:24:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Schwarzenbac](https://avatars.discourse-cdn.com/v4/letter/w/90db22/32.png) [@William\_Schwarzenbac](https://discuss.elastic.co/u/William_Schwarzenbac)\
**Post date:** [August 9, 2011, 4:24am UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/1 "2011-08-09T04:24:41Z")

</div>

I'm trying to get a quick and dirty autocomplete implementation  
working and thought a decent approach would be to fetch the  
highlighted phrase for a prefix phrase query and be done with it.  
However, no highlights are returned for a text\_prefix\_phrase query. An  
example curl:

curl '[http://localhost:9200/test\_index/test\_type/\_search?pretty=true](http://localhost:9200/test_index/test_type/_search?pretty=true)' -  
d   
'{  
"highlight":{  
"fields": {  
"name": {}  
}  
},  
"query":{  
"text\_phrase\_prefix":{  
"name": "Walla Wa"  
}  
}}'

This returns a non-empty result with no highlights. On the other hand,  
a text\_phrase query returns the highlights.  
Any help would be appreciated.

Cheers,  
Will

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 9, 2011, 9:24am UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/2 "2011-08-09T09:24:54Z")

</div>

Which version are you using?

On Tue, Aug 9, 2011 at 7:24 AM, William Schwarzenbach [wmschwa@gmail.com](mailto:wmschwa@gmail.com)wrote:

> I'm trying to get a quick and dirty autocomplete implementation  
> working and thought a decent approach would be to fetch the  
> highlighted phrase for a prefix phrase query and be done with it.  
> However, no highlights are returned for a text\_prefix\_phrase query. An  
> example curl:
> 
> curl '[http://localhost:9200/test\_index/test\_type/\_search?pretty=true](http://localhost:9200/test_index/test_type/_search?pretty=true)' -  
> d   
> '{  
> "highlight":{  
> "fields": {  
> "name": {}  
> }  
> },  
> "query":{  
> "text\_phrase\_prefix":{  
> "name": "Walla Wa"  
> }  
> }}'
> 
> This returns a non-empty result with no highlights. On the other hand,  
> a text\_phrase query returns the highlights.  
> Any help would be appreciated.
> 
> Cheers,  
> Will

---

<div class="post-metadata">

**Author:** ![William\_Schwarzenbac](https://avatars.discourse-cdn.com/v4/letter/w/90db22/32.png) [@William\_Schwarzenbac](https://discuss.elastic.co/u/William_Schwarzenbac)\
**Post date:** [August 9, 2011, 5:48pm UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/3 "2011-08-09T17:48:56Z")

</div>

Hi Shay,  
Version is 0.16.2. I'm guessing it's time to upgrade.  
Thanks,  
Will

On Tue, Aug 9, 2011 at 2:24 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Which version are you using?
> 
> On Tue, Aug 9, 2011 at 7:24 AM, William Schwarzenbach [wmschwa@gmail.com](mailto:wmschwa@gmail.com)wrote:
> 
> > I'm trying to get a quick and dirty autocomplete implementation  
> > working and thought a decent approach would be to fetch the  
> > highlighted phrase for a prefix phrase query and be done with it.  
> > However, no highlights are returned for a text\_prefix\_phrase query. An  
> > example curl:
> > 
> > curl '[http://localhost:9200/test\_index/test\_type/\_search?pretty=true](http://localhost:9200/test_index/test_type/_search?pretty=true)' -  
> > d   
> > '{  
> > "highlight":{  
> > "fields": {  
> > "name": {}  
> > }  
> > },  
> > "query":{  
> > "text\_phrase\_prefix":{  
> > "name": "Walla Wa"  
> > }  
> > }}'
> > 
> > This returns a non-empty result with no highlights. On the other hand,  
> > a text\_phrase query returns the highlights.  
> > Any help would be appreciated.
> > 
> > Cheers,  
> > Will

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 9, 2011, 6:23pm UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/4 "2011-08-09T18:23:05Z")

</div>

Yea, it should be fixed in 0.17.

On Tue, Aug 9, 2011 at 8:48 PM, William Schwarzenbach [wmschwa@gmail.com](mailto:wmschwa@gmail.com)wrote:

> Hi Shay,  
> Version is 0.16.2. I'm guessing it's time to upgrade.  
> Thanks,  
> Will
> 
> On Tue, Aug 9, 2011 at 2:24 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > Which version are you using?
> > 
> > On Tue, Aug 9, 2011 at 7:24 AM, William Schwarzenbach [wmschwa@gmail.com](mailto:wmschwa@gmail.com)wrote:
> > 
> > > I'm trying to get a quick and dirty autocomplete implementation  
> > > working and thought a decent approach would be to fetch the  
> > > highlighted phrase for a prefix phrase query and be done with it.  
> > > However, no highlights are returned for a text\_prefix\_phrase query. An  
> > > example curl:
> > > 
> > > curl '[http://localhost:9200/test\_index/test\_type/\_search?pretty=true](http://localhost:9200/test_index/test_type/_search?pretty=true)' -  
> > > d   
> > > '{  
> > > "highlight":{  
> > > "fields": {  
> > > "name": {}  
> > > }  
> > > },  
> > > "query":{  
> > > "text\_phrase\_prefix":{  
> > > "name": "Walla Wa"  
> > > }  
> > > }}'
> > > 
> > > This returns a non-empty result with no highlights. On the other hand,  
> > > a text\_phrase query returns the highlights.  
> > > Any help would be appreciated.
> > > 
> > > Cheers,  
> > > Will

---

<div class="post-metadata">

**Author:** ![William\_Schwarzenbac](https://avatars.discourse-cdn.com/v4/letter/w/90db22/32.png) [@William\_Schwarzenbac](https://discuss.elastic.co/u/William_Schwarzenbac)\
**Post date:** [August 9, 2011, 6:33pm UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/5 "2011-08-09T18:33:21Z")

</div>

Just tried on 0.17.4. Same behavior. I don't think the release notes mention  
this problem.

Just a note: I've tried with both highlighters by specifying term\_vector on  
the field in question and by leaving it unspecified.

-Will

On Tue, Aug 9, 2011 at 11:23 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Yea, it should be fixed in 0.17.
> 
> On Tue, Aug 9, 2011 at 8:48 PM, William Schwarzenbach [wmschwa@gmail.com](mailto:wmschwa@gmail.com)wrote:
> 
> > Hi Shay,  
> > Version is 0.16.2. I'm guessing it's time to upgrade.  
> > Thanks,  
> > Will
> > 
> > On Tue, Aug 9, 2011 at 2:24 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> > 
> > > Which version are you using?
> > > 
> > > On Tue, Aug 9, 2011 at 7:24 AM, William Schwarzenbach \<[wmschwa@gmail.com](mailto:wmschwa@gmail.com)
> > > 
> > > > wrote:
> > > 
> > > > I'm trying to get a quick and dirty autocomplete implementation  
> > > > working and thought a decent approach would be to fetch the  
> > > > highlighted phrase for a prefix phrase query and be done with it.  
> > > > However, no highlights are returned for a text\_prefix\_phrase query. An  
> > > > example curl:
> > > > 
> > > > curl '[http://localhost:9200/test\_index/test\_type/\_search?pretty=true](http://localhost:9200/test_index/test_type/_search?pretty=true)' -  
> > > > d   
> > > > '{  
> > > > "highlight":{  
> > > > "fields": {  
> > > > "name": {}  
> > > > }  
> > > > },  
> > > > "query":{  
> > > > "text\_phrase\_prefix":{  
> > > > "name": "Walla Wa"  
> > > > }  
> > > > }}'
> > > > 
> > > > This returns a non-empty result with no highlights. On the other hand,  
> > > > a text\_phrase query returns the highlights.  
> > > > Any help would be appreciated.
> > > > 
> > > > Cheers,  
> > > > Will

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 9, 2011, 8:41pm UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/6 "2011-08-09T20:41:12Z")

</div>

Can you gist a recreation then? Simpler for me to get started at looking at  
it.

On Tue, Aug 9, 2011 at 9:33 PM, William Schwarzenbach [wmschwa@gmail.com](mailto:wmschwa@gmail.com)wrote:

> Just tried on 0.17.4. Same behavior. I don't think the release notes  
> mention this problem.
> 
> Just a note: I've tried with both highlighters by specifying term\_vector on  
> the field in question and by leaving it unspecified.
> 
> -Will
> 
> On Tue, Aug 9, 2011 at 11:23 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > Yea, it should be fixed in 0.17.
> > 
> > On Tue, Aug 9, 2011 at 8:48 PM, William Schwarzenbach [wmschwa@gmail.com](mailto:wmschwa@gmail.com)wrote:
> > 
> > > Hi Shay,  
> > > Version is 0.16.2. I'm guessing it's time to upgrade.  
> > > Thanks,  
> > > Will
> > > 
> > > On Tue, Aug 9, 2011 at 2:24 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> > > 
> > > > Which version are you using?
> > > > 
> > > > On Tue, Aug 9, 2011 at 7:24 AM, William Schwarzenbach \<  
> > > > [wmschwa@gmail.com](mailto:wmschwa@gmail.com)\> wrote:
> > > > 
> > > > > I'm trying to get a quick and dirty autocomplete implementation  
> > > > > working and thought a decent approach would be to fetch the  
> > > > > highlighted phrase for a prefix phrase query and be done with it.  
> > > > > However, no highlights are returned for a text\_prefix\_phrase query. An  
> > > > > example curl:
> > > > > 
> > > > > ## curl '[http://localhost:9200/test\_index/test\_type/\_search?pretty=true](http://localhost:9200/test_index/test_type/_search?pretty=true)'
> > > > > 
> > > > > d   
> > > > > '{  
> > > > > "highlight":{  
> > > > > "fields": {  
> > > > > "name": {}  
> > > > > }  
> > > > > },  
> > > > > "query":{  
> > > > > "text\_phrase\_prefix":{  
> > > > > "name": "Walla Wa"  
> > > > > }  
> > > > > }}'
> > > > > 
> > > > > This returns a non-empty result with no highlights. On the other hand,  
> > > > > a text\_phrase query returns the highlights.  
> > > > > Any help would be appreciated.
> > > > > 
> > > > > Cheers,  
> > > > > Will

---

<div class="post-metadata">

**Author:** ![William\_Schwarzenbac](https://avatars.discourse-cdn.com/v4/letter/w/90db22/32.png) [@William\_Schwarzenbac](https://discuss.elastic.co/u/William_Schwarzenbac)\
**Post date:** [August 9, 2011, 9:29pm UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/7 "2011-08-09T21:29:06Z")

</div>

Gisted a script:

> <https://gist.github.com/anonymous/1135250>

should work as an end-to-end repro of the issue.

Thanks,  
Will

On Tue, Aug 9, 2011 at 1:41 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Can you gist a recreation then? Simpler for me to get started at looking at  
> it.
> 
> On Tue, Aug 9, 2011 at 9:33 PM, William Schwarzenbach [wmschwa@gmail.com](mailto:wmschwa@gmail.com)wrote:
> 
> > Just tried on 0.17.4. Same behavior. I don't think the release notes  
> > mention this problem.
> > 
> > Just a note: I've tried with both highlighters by specifying term\_vector  
> > on the field in question and by leaving it unspecified.
> > 
> > -Will
> > 
> > On Tue, Aug 9, 2011 at 11:23 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> > 
> > > Yea, it should be fixed in 0.17.
> > > 
> > > On Tue, Aug 9, 2011 at 8:48 PM, William Schwarzenbach \<[wmschwa@gmail.com](mailto:wmschwa@gmail.com)
> > > 
> > > > wrote:
> > > 
> > > > Hi Shay,  
> > > > Version is 0.16.2. I'm guessing it's time to upgrade.  
> > > > Thanks,  
> > > > Will
> > > > 
> > > > On Tue, Aug 9, 2011 at 2:24 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> > > > 
> > > > > Which version are you using?
> > > > > 
> > > > > On Tue, Aug 9, 2011 at 7:24 AM, William Schwarzenbach \<  
> > > > > [wmschwa@gmail.com](mailto:wmschwa@gmail.com)\> wrote:
> > > > > 
> > > > > > I'm trying to get a quick and dirty autocomplete implementation  
> > > > > > working and thought a decent approach would be to fetch the  
> > > > > > highlighted phrase for a prefix phrase query and be done with it.  
> > > > > > However, no highlights are returned for a text\_prefix\_phrase query. An  
> > > > > > example curl:
> > > > > > 
> > > > > > ## curl '[http://localhost:9200/test\_index/test\_type/\_search?pretty=true](http://localhost:9200/test_index/test_type/_search?pretty=true)'
> > > > > > 
> > > > > > d   
> > > > > > '{  
> > > > > > "highlight":{  
> > > > > > "fields": {  
> > > > > > "name": {}  
> > > > > > }  
> > > > > > },  
> > > > > > "query":{  
> > > > > > "text\_phrase\_prefix":{  
> > > > > > "name": "Walla Wa"  
> > > > > > }  
> > > > > > }}'
> > > > > > 
> > > > > > This returns a non-empty result with no highlights. On the other hand,  
> > > > > > a text\_phrase query returns the highlights.  
> > > > > > Any help would be appreciated.
> > > > > > 
> > > > > > Cheers,  
> > > > > > Will

---

<div class="post-metadata">

**Author:** ![chenry12](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chenry12](https://discuss.elastic.co/u/chenry12)\
**Post date:** [June 21, 2012, 10:20pm UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/8 "2012-06-21T22:20:17Z")

</div>

Hello,

I have the same problems than William.  
I'm working the elasticsearch version 0.19.4.  
Is there an error on his script ? or there's a feature not yet implemented ?

Thanks,  
Christophe.

On Tuesday, August 9, 2011 11:29:06 PM UTC+2, William Schwarzenbach wrote:

> Gisted a script:
> 
> [This is a script to reproduce a highlighting issue with the text\_phrase\_prefix query · GitHub](https://gist.github.com/1135250)
> 
> should work as an end-to-end repro of the issue.
> 
> Thanks,  
> Will

---

<div class="post-metadata">

**Author:** ![Thomas\_Buechner](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@Thomas\_Buechner](https://discuss.elastic.co/u/Thomas_Buechner)\
**Post date:** [January 24, 2013, 11:01pm UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/9 "2013-01-24T23:01:08Z")

</div>

Hi there,

I experience the same problem using the current 20.2.0 release. Is this a  
bug or is there a conceptual problem?

Thanks,  
Thomas

> 

--

---

<div class="post-metadata">

**Author:** ![Martin\_Kresse](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@Martin\_Kresse](https://discuss.elastic.co/u/Martin_Kresse)\
**Post date:** [February 5, 2013, 1:52pm UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/10 "2013-02-05T13:52:04Z")

</div>

I had the same problem with 0.20.2, which disappeared after updating to the  
current 0.20.4 release.

Cheers,  
Martin

On Friday, January 25, 2013 12:01:08 AM UTC+1, Thomas Buechner wrote:

> Hi there,
> 
> I experience the same problem using the current 20.2.0 release. Is this a  
> bug or is there a conceptual problem?
> 
> Thanks,  
> Thomas
> 
> >

--  
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).  
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, 2:52am UTC](https://discuss.elastic.co/t/highlighting-a-text-phrase-prefix-query/5094/11 "2017-07-06T02:52:58Z")

</div>


