Search code examples
sortinghadoopelasticsearchelasticsearch-plugin

Elasticsearch uri sort by fieldname


How to order particular field in ES 5.4 version through query url

http://localhost:9200/companies/emp/_search?q=*&sort=name:desc

here i am searching emp and displaying emp name in descending order. I am getting thi exception

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

Any help ?


Solution

  • http://localhost:9200/companies/emp/_search?q=*&sort=name.keyword:desc

    You need to put keyword after name