# ElasticSearch sort not working with es php library 8.2

**URL:** <https://discuss.elastic.co/t/elasticsearch-sort-not-working-with-es-php-library-8-2/359586>\
**Category:** Elasticsearch\
**Created:** [May 16, 2024, 4:24am UTC](https://discuss.elastic.co/t/elasticsearch-sort-not-working-with-es-php-library-8-2/359586 "2024-05-16T04:24:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sajeeda](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@sajeeda](https://discuss.elastic.co/u/sajeeda)\
**Post date:** [May 16, 2024, 4:24am UTC](https://discuss.elastic.co/t/elasticsearch-sort-not-working-with-es-php-library-8-2/359586/1 "2024-05-16T04:24:04Z")

</div>

Hi All,

Trying to add sort option in query while retriving the data from Elasticsearch.  
Have been getting the below error

PHP Fatal error: Uncaught Elastic\Elasticsearch\Exception\ClientResponseException: 400 Bad Request: {"error":{"root\_cause":[{"type":"parsing\_exception","reason":"request does not support [sort]","line":1,"col":186}],"type":"parsing\_exception","reason":"request does not support [sort]","line":1,"col":186},"status":400} .

But the sort option works well in kibana dev tools. Is there any issue with the library?

Below is the query which i am trying

```auto
{
    "index": "indexname",
    "search_type": "dfs_query_then_fetch",
    "track_total_hits": true,
    "body": {
        "query": {
            "bool": {
                "must": [
                    {
                        "range": {
                            "amount": [
                                {
                                    "lte": 1500000
                                }
                            ]
                        }
                    }
                ],
                "should": [],
                "must_not": [],
                "filter": []
            }
        },
        "from": 0,
        "size": 100,
        "sort": {
            "name": {
                "order": "asc"
            }
        }
    }
}

```
