I have been using ES 5.4.0 version and created index and documents (student data). when i do search based on age , _search end point is returning value and output is as expected. Did the same for name desc option. i am getting below exception
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "students",
"node": "MESiRCvSSgqMNWEVwMevMg",
"reason": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
what could be the reason. As per log i have to add fileddata=true. any reason behind this.
http://localhost:9200/students/data/_search?q=montana&sort=age:desc - working fine.
http://localhost:9200/students/data/_search?q=montana&sort=name:desc - not working
http://localhost:9200/students/data/_search?q=montana&sort=name:desc&fielddata=true - added fielddata - not wokring
// http://localhost:9200/students?
{
"students": {
"aliases": {
},
"mappings": {
"data": {
"properties": {
"age": {
"type": "long"
},
"city": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"company": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"email": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"gender": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"phone": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"state": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"street": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
},
"settings": {
"index": {
"creation_date": "1530174012103",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "PrtajDL0SwS-tTX7Gm_YQw",
"version": {
"created": "5040099"
},
"provided_name": "students"
}
}
}
}
curl -XGET localhost:9200/students? (please update your question with the result)