# Sorting by Relevance Score and Sold Counts

**URL:** <https://discuss.elastic.co/t/sorting-by-relevance-score-and-sold-counts/303810>\
**Category:** Elasticsearch\
**Created:** [May 3, 2022, 9:01am UTC](https://discuss.elastic.co/t/sorting-by-relevance-score-and-sold-counts/303810 "2022-05-03T09:01:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![icgncl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icgncl/32/97769_2.png) [@icgncl](https://discuss.elastic.co/u/icgncl)\
**Post date:** [May 3, 2022, 9:01am UTC](https://discuss.elastic.co/t/sorting-by-relevance-score-and-sold-counts/303810/1 "2022-05-03T09:01:09Z")

</div>

Hello everyone,  
I want to sort results according to sold counts. However, the criteria should also include relevance score. For example, assume that for a "X" product, sold count is 100 and relevance score 3; for a "Y" product, sold count 105 and relevance score 1 then I want X to be sorted before Y. In the later versions (ES 8), I would be able to use [rank\_feature](https://www.elastic.co/guide/en/elasticsearch/reference/current/rank-feature.html). In the previous versions, is there alternative for it?

---

<div class="post-metadata">

**Author:** ![icgncl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icgncl/32/97769_2.png) [@icgncl](https://discuss.elastic.co/u/icgncl)\
**Post date:** [May 3, 2022, 1:28pm UTC](https://discuss.elastic.co/t/sorting-by-relevance-score-and-sold-counts/303810/3 "2022-05-03T13:28:55Z")

</div>

Have you ever used rank\_feature or similar features in the previous versions?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 3, 2022, 2:14pm UTC](https://discuss.elastic.co/t/sorting-by-relevance-score-and-sold-counts/303810/4 "2022-05-03T14:14:58Z")

</div>

I'm a bit confused. Rank feature is available in Elasticsearch 7 already?

You could use a script score, but that would be a major performance difference between those two queries, but may be worth a try depending on your data set size and speed expectations.

---

<div class="post-metadata">

**Author:** ![icgncl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icgncl/32/97769_2.png) [@icgncl](https://discuss.elastic.co/u/icgncl)\
**Post date:** [May 3, 2022, 2:56pm UTC](https://discuss.elastic.co/t/sorting-by-relevance-score-and-sold-counts/303810/5 "2022-05-03T14:56:58Z")

</div>

The feature comes with ES 7, however, in my prod env ES 6 is installed therefore I cannot use it on there.

---

<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 31, 2022, 2:57pm UTC](https://discuss.elastic.co/t/sorting-by-relevance-score-and-sold-counts/303810/6 "2022-05-31T14:57:02Z")

</div>

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