# Nested sorting does not work with \`\_last\` missing

**URL:** <https://forum.opensearch.org/t/nested-sorting-does-not-work-with-last-missing/24296>\
**Category:** OpenSearch\
**Tags:** discuss\
**Created:** [May 7, 2025, 10:28pm UTC](https://forum.opensearch.org/t/nested-sorting-does-not-work-with-last-missing/24296 "2025-05-07T22:28:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![UmangKamdar](https://avatars.discourse-cdn.com/v4/letter/u/ad7895/32.png) [@UmangKamdar](https://forum.opensearch.org/u/UmangKamdar)\
**Post date:** [May 7, 2025, 10:28pm UTC](https://forum.opensearch.org/t/nested-sorting-does-not-work-with-last-missing/24296/1 "2025-05-07T22:28:27Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
v 2.17.0

**Describe the issue** :  
This query works fine

```auto
{
  "size": 20,
  "query": {
    "match_all": {}
  },
  "sort": [
    {
      "prod.domains.score": {
        "order": "desc",
        "missing": "_first",
        "unmapped_type": "integer",
        "nested": {
          "path": "prod.domains",
          "filter": {
            "term": {
              "prod.domains.domain_key": "KEY"
            }
          }
        }
      }
    }
  ]
}

```

But this query DOESN’T works (I have just changed the missing type from \_first to \_last here)

```auto
{
  "size": 20,
  "query": {
    "match_all": {}
  },
  "sort": [
    {
      "prod.domains.score": {
        "order": "desc",
        "missing": "_last",
        "unmapped_type": "integer",
        "nested": {
          "path": "prod.domains",
          "filter": {
            "term": {
              "prod.domains.domain_key": "KEY"
            }
          }
        }
      }
    }
  ]
}

```

I’m getting this error

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "unsupported_operation_exception",
        "reason": "unsupported_operation_exception: null"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "abc",
        "node": "Dqfbq8GN......",
        "reason": {
          "type": "unsupported_operation_exception",
          "reason": "unsupported_operation_exception: null"
        }
      }
    ]
  },
  "status": 500
}

```

**Configuration** :

**Relevant Logs or Screenshots** :
