Basic criteria for sorting

I am creating a simple index and trying to sort as follows:

{
  "mappings": {
    "type_mapping": {
      "properties": {
        "checksort": {
          "type": "text"
        }
      }
    }
  }
}

And I try to sort as below:

{
  "sort": [
    {
      "field": "checksort",
      "direction": "DESC"
    }
  ]
}

But this results in an exception:

"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "No enum constant org.elasticsearch.search.sort.SortOrder.CHECKSORT"}
]

I know this is a basic miss but stuck and requesting your help

Hey,

can you point to the documentation where you got that JSON from? I can't seem to spot it on our docs. Have you tried sorting like mentioned in the docs at https://www.elastic.co/guide/en/elasticsearch/reference/7.3/search-request-body.html#request-body-search-sort

"sort" : [ { "checksort" : {"order" : "desc"}} ]

Also please mention the elasticsearch version you are using as well as provide a fully reproducible example including index/document creation and a complete query.

Thank you!

--Alex

1 Like

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