I have a requirement where I need to implement search recommendations and I have opted for the search as you type field. My existing mapping for the field was "text" and now I have changed it to "search_as_you_type" and reindex the index to get the updated mapping. While querying for the data I am getting below exception.
Mapping:
"properties": {
"type": {
"type": "keyword"
},
"title": {
"type": "search_as_you_type",
"store": true
},
Request:
{
"from": 0,
"size": 10,
"timeout": "5000ms",
"query": {
"bool": {
"must": [{
"bool": {
"must": [{
"bool": {
"should": [ {
"query_string": {
"query": "Star",
"default_field": "title",
"fields": [],
"type": "best_fields",
"default_operator": "or",
"max_determinized_states": 10000,
"enable_position_increments": true,
"fuzziness": "AUTO",
"fuzzy_prefix_length": 0,
"fuzzy_max_expansions": 50,
"phrase_slop": 0,
"analyze_wildcard": true,
"escape": false,
"auto_generate_synonyms_phrase_query": true,
"fuzzy_transpositions": true,
"boost": 2.0
}
}],
"adjust_pure_negative": true,
"minimum_should_match": "1",
"boost": 1.0
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
}
}
Exception:
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Fielddata is not supported on field [title] of type [search_as_you_type]"
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "application",
"node" : "V0bTylUqSXe025iSbyTpKw",
"reason" : {
"type" : "illegal_argument_exception",
"reason" : "Fielddata is not supported on field [title] of type [search_as_you_type]"
}
}
],
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Fielddata is not supported on field [title] of type [search_as_you_type]",
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Fielddata is not supported on field [__doc_title] of type [search_as_you_type]"
}
}
},
"status" : 400
}
Please suggest what is wrong here??