# Match\_phrase\_prefix : Can only use phrase prefix queries on text fields

**URL:** https://discuss.elastic.co/t/match-phrase-prefix-can-only-use-phrase-prefix-queries-on-text-fields/231807
**Category:** Elasticsearch
**Created:** [May 8, 2020, 10:24pm UTC](https://discuss.elastic.co/t/match-phrase-prefix-can-only-use-phrase-prefix-queries-on-text-fields/231807 "2020-05-08T22:24:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![harishmce2005](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@harishmce2005](https://discuss.elastic.co/u/harishmce2005)
#### Post date: [May 8, 2020, 10:24pm UTC](https://discuss.elastic.co/t/match-phrase-prefix-can-only-use-phrase-prefix-queries-on-text-fields/231807/1 "2020-05-08T22:24:47Z")

</div>

I have upgraded one of our Elastic search version from 6.4.2 to 7.1.1.

In one of our search query, we configured a 'match\_phrase\_prefix' on a 'keyword' type field and it was working in 6.4.2, please see the index structure below: -

curl -XPOST 'localhost:9200/city\_index' -H 'Content-Type: application/json' -d '{  
"settings": {  
"analysis": {  
"normalizer": {  
"lowercase\_normalizer": {  
"type": "custom",  
"char\_filter": ,  
"filter": ["lowercase", "asciifolding"]  
}  
}  
}  
},  
"mappings": {  
"drug": {  
"properties": {  
"city": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"normalizer": "lowercase\_normalizer"  
}  
},  
"fielddata": true  
}  
}   
}  
}  
}  
'  
Search Query :-  
curl -XGET '[http://localhost:9200/city\_index/\_search?pretty](http://localhost:9200/city_index/_search?pretty)' -H 'Content-Type: application/json' -d '{  
"query": {  
"match\_phrase\_prefix" : {  
"city.keyword" : {  
"query" : "York"  
}  
}  
}  
}'

The Quey was working fine in 6.4.2. But after we migrate the same structure into Elastic 7.1.1 version we are getting below error when searching using the same query.

"Can only use phrase prefix queries on text fields - not on [city.keyword] which is of type [keyword]"

As per the Elastic search documentation, the mapping types are deprecated in 7.0.0and will be removed from 8.0.0.  
[https://www.elastic.co/guide/en/elasticsearch/reference/6.4/removal-of-types.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/removal-of-types.html)

Am I using the right way for querying data from a 'keyword' field using the 'match\_phrase\_prefix' query?

Any help is much appreciated.

Thanks in Advance.

---

<div class="post-metadata">

### Author: ![PRAVEEN\_KUMAR\_P](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/praveen_kumar_p/32/68136_2.png) [@PRAVEEN\_KUMAR\_P](https://discuss.elastic.co/u/PRAVEEN_KUMAR_P)
#### Post date: [May 12, 2020, 9:51am UTC](https://discuss.elastic.co/t/match-phrase-prefix-can-only-use-phrase-prefix-queries-on-text-fields/231807/2 "2020-05-12T09:51:04Z")

</div>

Hi, I am also facing the some issue when migrated to 7.6.0. Can anyone guide us to fix this please .

Thanks,  
Praveen

---

<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: [June 9, 2020, 9:51am UTC](https://discuss.elastic.co/t/match-phrase-prefix-can-only-use-phrase-prefix-queries-on-text-fields/231807/3 "2020-06-09T09:51:04Z")

</div>

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