Nested sorting differs between ES7 and ES8?

Thanks for the detailed script. I check it and you're right, it's ok in 7.17.12 but fails in 8.x.

I believe that in 7.17 there was may be a bug which has been fixed in 8?

BTW, I updated and simplified your script. In case someone else wants to test/comment it:

DELETE /test-index
PUT /test-index
{
  "mappings": {
    "properties": {
      "name": {
        "type": "text"
      },
      "trace": {
        "type": "nested",
        "properties": {
          "origami": {
            "properties": {
              "timestamp": {
                "type": "long"
              }
            }
          }
        }
      }
    }
  }
}

POST /test-index/_bulk
{ "index" : { "_id" : "1" } }
{ "trace" : { "origami": { "timestamp": 1688732801 } } }
{ "index" : { "_id" : "2" } }
{ "trace" : { "origami": { "timestamp": 1688732701 } } }
{ "index" : { "_id" : "3" } }
{ "trace" : { "origami": { "timestamp": 1688732601 } } }


GET /test-index/_search
{
  "sort": [
    {
      "trace.origami.timestamp": {
        "nested": {
          "path": "trace"
        }
      }
    }
  ]
}

# this fails in ES8 but works in ES7

GET /test-index/_search
{
  "sort": [
    {
      "trace.origami.timestamp": {
        "nested": {
          "path": "trace"
        }
      }
    }
  ]
}