Sort according to day not hour

When I see my data and timestamp field, sort of them are corresponding to hour not date. How can tell to opensearch store according to date?

Hi @m_pahlevanzadeh,

You can sort with:

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

or if you want more control you can always use painless something like:

 "sort": [
    {
      "_script": {
        "type": "number",
        "script": {
          "source": "doc[\"<date_field>\"].value.toInstant().toEpochMilli()", # this should convert to milliseconds for further sorting..
          "lang": "painless"
        },
        "order": "desc"

best,
mj