# Search\_after doesn't work when sorting descendent

**URL:** <https://discuss.elastic.co/t/search-after-doesnt-work-when-sorting-descendent/230386>\
**Category:** Elasticsearch\
**Created:** [April 29, 2020, 2:02pm UTC](https://discuss.elastic.co/t/search-after-doesnt-work-when-sorting-descendent/230386 "2020-04-29T14:02:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yv\_2904](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@yv\_2904](https://discuss.elastic.co/u/yv_2904)\
**Post date:** [April 29, 2020, 2:02pm UTC](https://discuss.elastic.co/t/search-after-doesnt-work-when-sorting-descendent/230386/1 "2020-04-29T14:02:20Z")

</div>

I am implementing a sear\_after for cursor pagination, my sort is based on a unique Id that is a text field. When I tried to sort this field desc the search\_after doesn't return any result. If I sort asc, it returns results. Can someone help to understand why is this behavior?  
this is my query:

```auto
GET _index/_search
{
  "size": 20,
  "sort": [
    {
      "hId.keyword": {
        "order": "desc"
      }
    }
  ],
  "search_after": [
    "J18347805"
  ],
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "customer.keyword": {
              "value": "5fgfggg"
            }
          }
        }
      ]
    }
  }
}

```

I get this as a result

```auto
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 92,
    "max_score" : null,
    "hits" : []
  }
}

```

---

<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:** [May 27, 2020, 2:02pm UTC](https://discuss.elastic.co/t/search-after-doesnt-work-when-sorting-descendent/230386/2 "2020-05-27T14:02:21Z")

</div>

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