Elastic search query fail: No mapping found for [@timestamp] in order to sort on

2.9k Views Asked by At

Here is the mapping. I have a property named @timestamp.

{
  "my_index" : {
    "mappings" : {
      "properties" : {
        "@timestamp" : {
          "type" : "date_nanos"
        }
      }
    }
  }
}

But when I query like this:

{
   "sort" : {
        "@timestamp" : "desc"
    }
}

I got an error: No mapping found for [@timestamp] in order to sort on.
I found some solution using unmapping_type, but I have definition in the property. Could someone help explain this case? I just started to use elasticsearch. Thanks.

1

There are 1 best solutions below

2
Val On

You need to query on your specific index

GET my_index/_search

And not

GET /_search

Because otherwise you'll hit all indexes in your cluster and the odds are high that one of them doesn't have a @timestamp field.