# Match\_phrase\_prefix does not work with single term and \_all field

**URL:** <https://discuss.elastic.co/t/match-phrase-prefix-does-not-work-with-single-term-and--all-field/67025>\
**Category:** Elasticsearch\
**Created:** [November 23, 2016, 6:36pm UTC](https://discuss.elastic.co/t/match-phrase-prefix-does-not-work-with-single-term-and--all-field/67025 "2016-11-23T18:36:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tenhavenator](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@tenhavenator](https://discuss.elastic.co/u/tenhavenator)\
**Post date:** [November 23, 2016, 6:36pm UTC](https://discuss.elastic.co/t/match-phrase-prefix-does-not-work-with-single-term-and--all-field/67025/1 "2016-11-23T18:36:39Z")

</div>

I have a field that looks like this: "Address": "3478 GLAMORGAN RD". Using Elasticsearch 2.3.1

When using the match\_phrase\_prefix query on the \_all field with a single term, nothing will be returned  
Example:  
{  
"match\_phrase\_prefix":{  
"\_all": "glamor"  
}  
}

Using the profile=true option I can see that this is generating the following Lucene query:  
{  
"query\_type":"TermQuery",  
"lucene":"\_all:glamor",  
...  
}

Of course this does not match anything because there is no term "glamor".

When using the match\_phrase\_prefix query on the Address field with a single term, the expected results are returned.  
Example:  
{  
"match\_phrase\_prefix":{  
"Address": "gl"  
}  
}

Using the profile=true option I can see that this is generating the following Lucene query:  
{  
"query\_type":"BooleanQuery",  
"lucene":"attributes.Address:glenelg attributes.Address:glynnwood attributes.Address:glamorgan",  
...  
"children":[  
{  
"query\_type":"TermQuery",  
"lucene":"attributes.Address:glenelg",  
...  
},  
{  
"query\_type":"TermQuery",  
"lucene":"attributes.Address:glynnwood",  
...  
},  
{  
"query\_type":"TermQuery",  
"lucene":"attributes.Address:glamorgan",  
...  
}  
]  
}

I have tried increasing the max expansion parameter, but this did not help. The query on the \_all field will work just fine when using more than one term.  
Example:  
{  
"match\_phrase\_prefix":{  
"\_all": "3478 glamor"  
}  
}

Any idea why a single term cannot be used to prefix match when using the \_all field?

---

<div class="post-metadata">

**Author:** ![tenhavenator](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@tenhavenator](https://discuss.elastic.co/u/tenhavenator)\
**Post date:** [November 23, 2016, 7:41pm UTC](https://discuss.elastic.co/t/match-phrase-prefix-does-not-work-with-single-term-and--all-field/67025/2 "2016-11-23T19:41:03Z")

</div>

I see this was bug that was fixed in Elasticsearch 2.4.2

---

<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:** [December 21, 2016, 7:41pm UTC](https://discuss.elastic.co/t/match-phrase-prefix-does-not-work-with-single-term-and--all-field/67025/3 "2016-12-21T19:41:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
