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' -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
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.