# Index sorting with two order values in the same field

**URL:** <https://discuss.elastic.co/t/index-sorting-with-two-order-values-in-the-same-field/327333>\
**Category:** Elasticsearch\
**Created:** [March 9, 2023, 8:33am UTC](https://discuss.elastic.co/t/index-sorting-with-two-order-values-in-the-same-field/327333 "2023-03-09T08:33:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joaoantao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joaoantao/32/6546_2.png) [@joaoantao](https://discuss.elastic.co/u/joaoantao)\
**Post date:** [March 9, 2023, 8:33am UTC](https://discuss.elastic.co/t/index-sorting-with-two-order-values-in-the-same-field/327333/1 "2023-03-09T08:33:53Z")

</div>

I am trying to improve queries in one index with ~ 125 million documents and 3 shards. Most of the queries hitting this index have a sort order for a given field with values ascending and descending.

Currently the index settings are the following:

```auto
{
  "joao-2023-03-08_2" : {
    "settings" : {
      "index" : {
        "refresh_interval" : "60s",
        "number_of_shards" : "3",
        "provided_name" : "joao-2023-03-08_2",
        "creation_date" : "1678304042926",
        "sort" : {
          "field" : "a_field" ,
          "order" : "asc"
        },
        "number_of_replicas" : "1",
        "uuid" : "0-8O_yOYQ_iAxC2UUpaJGB",
        "version" : {
          "created" : "135248027"
        }
      }
    }
  }
}

```

The queries with sort a\_field=desc are slow. I know it is possible to modify the configuration and pass the same field (a\_field) in the array with the desc value. Doing this does not seem correct, but I am not sure how internally the segments will be created.

Is there anything I could read or do to improve this scenario?

Thanks in advance!

---

<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:** [April 6, 2023, 8:34am UTC](https://discuss.elastic.co/t/index-sorting-with-two-order-values-in-the-same-field/327333/2 "2023-04-06T08:34:02Z")

</div>

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