# How to ungroup related items from a query

**URL:** <https://discuss.elastic.co/t/how-to-ungroup-related-items-from-a-query/246670>\
**Category:** Elasticsearch\
**Created:** [August 27, 2020, 5:34pm UTC](https://discuss.elastic.co/t/how-to-ungroup-related-items-from-a-query/246670 "2020-08-27T17:34:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClubberLang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/clubberlang/32/72169_2.png) [@ClubberLang](https://discuss.elastic.co/u/ClubberLang)\
**Post date:** [August 27, 2020, 5:34pm UTC](https://discuss.elastic.co/t/how-to-ungroup-related-items-from-a-query/246670/1 "2020-08-27T17:34:13Z")

</div>

Hi,

I contact you because we are 3 guys trying to solve this problem, without result since weeks ☹  
Maybe you will have some ideas ? suggestions ? Anything 😉

Here is the situation, I have the following business model

- products
- store

Where a store can own a lot of products (thousands).

So, my query compute the score based on:

- a text filter
- a distance to a store

Now, imagine that I do a generic query like "shoes", the problem I have now  
is that it shows all the results from the first store, which is the closer (a group of 40, at 10km), then all from the next store (at 15km).

I'm looking for a way to "shuffle" without loosing (too much) of the relevancy. It is not very good to display all the result from the first group, then the next ☹

Does anyone has an idea ?

Thanks

---

<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:** [September 24, 2020, 5:34pm UTC](https://discuss.elastic.co/t/how-to-ungroup-related-items-from-a-query/246670/2 "2020-09-24T17:34:20Z")

</div>

Closed on September 24, 2020, 5:34pm UTC

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