# Rank and sort results of range query?

**URL:** <https://discuss.elastic.co/t/rank-and-sort-results-of-range-query/234052>\
**Category:** Elasticsearch\
**Created:** [May 24, 2020, 4:08pm UTC](https://discuss.elastic.co/t/rank-and-sort-results-of-range-query/234052 "2020-05-24T16:08:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgeographer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kgeographer/32/26217_2.png) [@kgeographer](https://discuss.elastic.co/u/kgeographer)\
**Post date:** [May 24, 2020, 4:08pm UTC](https://discuss.elastic.co/t/rank-and-sort-results-of-range-query/234052/1 "2020-05-24T16:08:59Z")

</div>

As far as I can tell, all docs with a range field overlapped by a query range with the default INTERSECTS operator are returned with a score of 1. However, I would like to rank results by the extent of that intersection/overlap. So that for example, a query with the range`{"gte":100,"lte":200}`, a document with a range `{"gte":110,"lte":200}` would score higher than one with a range `{"gte":190,"lte":400}`

Is this possible? Using ES 6.6 btw

---

<div class="post-metadata">

**Author:** ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)\
**Post date:** [June 2, 2020, 4:58pm UTC](https://discuss.elastic.co/t/rank-and-sort-results-of-range-query/234052/2 "2020-06-02T16:58:28Z")

</div>

Unfortunately, there is not way to apply custom scoring to range queries. As you correctly noticed, they all produce a constant score equal to `boost` value, which is 1 by default.

---

<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:** [June 30, 2020, 4:58pm UTC](https://discuss.elastic.co/t/rank-and-sort-results-of-range-query/234052/3 "2020-06-30T16:58:35Z")

</div>

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