# Sort data based on a field value

**URL:** <https://discuss.elastic.co/t/sort-data-based-on-a-field-value/315857>\
**Category:** Elasticsearch\
**Created:** [October 5, 2022, 10:14am UTC](https://discuss.elastic.co/t/sort-data-based-on-a-field-value/315857 "2022-10-05T10:14:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HadiKhai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hadikhai/32/111686_2.png) [@HadiKhai](https://discuss.elastic.co/u/HadiKhai)\
**Post date:** [October 5, 2022, 10:14am UTC](https://discuss.elastic.co/t/sort-data-based-on-a-field-value/315857/1 "2022-10-05T10:14:59Z")

</div>

Hello,

I am saving priority inside the data and I am looking for a way to boost the score based on the priority.

```auto
"userA":{
      "specialities": [
            {
              "speciality_priority": 3,
              "speciality_type": "a"
            },
            {
              "speciality_priority": 2,
              "speciality_type": "b"
            },
            {
              "speciality_priority": 1,
              "speciality_type": "c"
            }
      ]
}

"userB":{
      "specialities": [
            {
              "speciality_priority": 2,
              "speciality_type": "a"
            },
            {
              "speciality_priority": 1,
              "speciality_type": "b"
            },
            {
              "speciality_priority": 3,
              "speciality_type": "c"
            }
      ]
}

```

When I filter by speciality\_type "c", I want user A have a higher score than user B because of the speciality\_priority of A is 1 while the speciality\_priority of B is 3

How can I achieve this in Query DSL?

---

<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:** [November 2, 2022, 10:15am UTC](https://discuss.elastic.co/t/sort-data-based-on-a-field-value/315857/2 "2022-11-02T10:15:59Z")

</div>

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