# Sorting score and shuffle Adversiting results

**URL:** <https://discuss.elastic.co/t/sorting-score-and-shuffle-adversiting-results/104439>\
**Category:** Elasticsearch\
**Created:** [October 18, 2017, 5:44pm UTC](https://discuss.elastic.co/t/sorting-score-and-shuffle-adversiting-results/104439 "2017-10-18T17:44:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucashfreitas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucashfreitas/32/23166_2.png) [@lucashfreitas](https://discuss.elastic.co/u/lucashfreitas)\
**Post date:** [October 18, 2017, 5:44pm UTC](https://discuss.elastic.co/t/sorting-score-and-shuffle-adversiting-results/104439/1 "2017-10-18T17:44:41Z")

</div>

Hello guys,

My site use elasticsearch query for fetch adversiting data of customers. My query on elastic sort data considering **SCORE** calculed from score function. (_I use score because many properties make a difference in the order that the data should be returned from elastic, such as whether the ad is premium or not etc._)

I need to keep sorting by score, but i want to Shuffle data for elasticsearch brings adversiting from different customers, which are differentiated by the **customerID** field. As the records are sorted by score, elastic returns a certain flood, containing multiple pages with adversting from just one customer.

Basically i wanna keep soring by function score, avoid the flood and bring as much as more possible different customers adversiting, that is diferencied by field **customerID**

**PRATICAL EXAMPLE:**

I have customer A that have 80 adversiting.  
I have customer B that have 12 adversiting.

The adverstings of A and B are ordered by score and both ADS that elastic returns have a high score value. But when elasticsearch run the query is returned FIRST 80 adversiting of A and after 12 adversiting of B. Since my website is paging results, the adversiting of customer B will be shown only in last pages leaving customer B at a disadvantage.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [October 22, 2017, 12:17pm UTC](https://discuss.elastic.co/t/sorting-score-and-shuffle-adversiting-results/104439/2 "2017-10-22T12:17:12Z")

</div>

Could you provide an example of what you mean by this?

---

<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 19, 2017, 12:17pm UTC](https://discuss.elastic.co/t/sorting-score-and-shuffle-adversiting-results/104439/3 "2017-11-19T12:17:33Z")

</div>

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