# Elasticsearch nested sorting is not working

**URL:** <https://discuss.elastic.co/t/elasticsearch-nested-sorting-is-not-working/246491>\
**Category:** Elasticsearch\
**Created:** [August 26, 2020, 5:08pm UTC](https://discuss.elastic.co/t/elasticsearch-nested-sorting-is-not-working/246491 "2020-08-26T17:08:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishek\_chaturvedi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhishek_chaturvedi/32/74365_2.png) [@abhishek\_chaturvedi](https://discuss.elastic.co/u/abhishek_chaturvedi)\
**Post date:** [August 26, 2020, 5:08pm UTC](https://discuss.elastic.co/t/elasticsearch-nested-sorting-is-not-working/246491/1 "2020-08-26T17:08:16Z")

</div>

I want to sort below query based on responseDate:  
And every time I am returning some wrong BIG\_INTEGER in sort with each data. I think nested sort is not working properly. Kindly help:

```auto
{
  "size": 1000,
  "query": {
    "bool": {
      "must": [
        
        {
          "nested": {
            "path": "data",
            "query": {
              "nested": {
                "path": "data.sec",
                "query": {
                  "nested": {
                    "path": "data.sec.dataQuestions",
                    "query": {
                      "nested": {
                        "path": "data.sec.dataQuestions.question",
                        "query": {
                          "nested": {
                            "path": "data.sec.dataQuestions.question.answer",
                            "query": {
                              "exists": {
                                "field": "data.sec.dataQuestions.question.answer.other"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
              ]
    }
  },
    "sort": {
"data.responseDate": {
"order": "asc"
}
},
   
  "_source": [
    "data.sec.dataQuestions.question.answer.other",
    "data.sec.dataQuestions.question.title"
  ]
}
~~
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 23, 2020, 5:08pm UTC](https://discuss.elastic.co/t/elasticsearch-nested-sorting-is-not-working/246491/2 "2020-09-23T17:08:33Z")

</div>

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