No mapping found in order to sort on (Dates)

So I'm trying to order my logs by date. I'm currently querying http://localhost:9200/myindex/_search?pretty=true&sort="date" without the pretty, within a java app. When I do that, I'm getting the following error:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "query_shard_exception",
        "reason" : "No mapping found for [\"date\"] in order to sort on",
        "index_uuid" : "vbAJhP7bTGK4bLdOyX3IdA",
        "index" : "myindex"
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "myindex",
        "node" : "vWwnROc0Qiq-WGNRvRROoA",
        "reason" : {
          "type" : "query_shard_exception",
          "reason" : "No mapping found for [\"date\"] in order to sort on",
          "index_uuid" : "vbAJhP7bTGK4bLdOyX3IdA",
          "index" : "myindex"
        }
      }
    ]
  },
  "status" : 400
}

And when I querry _mapping, here are the results:

    {
  "myindex" : {
    "mappings" : {
      "doc" : {
        "properties" : {
          "date" : {
            "type" : "date",
            "format" : "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis"
          },
          "message" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "type" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
        }
      }
    }
  }
}

What do I need to do make it work ?

The right syntax is:

GET test/_search?sort=date

Not

GET test/_search?sort="date"

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