# Proportionally mix results from two different searches on same index

**URL:** <https://discuss.elastic.co/t/proportionally-mix-results-from-two-different-searches-on-same-index/223976>\
**Category:** Elasticsearch\
**Created:** [March 17, 2020, 5:05pm UTC](https://discuss.elastic.co/t/proportionally-mix-results-from-two-different-searches-on-same-index/223976 "2020-03-17T17:05:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![germangorodnev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/germangorodnev/32/64601_2.png) [@germangorodnev](https://discuss.elastic.co/u/germangorodnev)\
**Post date:** [March 17, 2020, 5:05pm UTC](https://discuss.elastic.co/t/proportionally-mix-results-from-two-different-searches-on-same-index/223976/1 "2020-03-17T17:05:37Z")

</div>

I have dating app where users can like\dislike each other.  
I use filters provided by user to search profiles, let's call these general results. I'd like to mix these with users who liked requesting user ( `liked` ) in some ratio, e.g. 1 to 5 (1 person who belongs to `liked` per 5 general profiles). Right now I implemented this via 2 separate queries and msearch, simplified query looks like this ( `liked` is an array of ids):

```auto
/_msearch

{ "index": "users" }
{
  "query": {
    "bool": {
      "must_not": [
        {
          "terms": {
            "_id": liked
          }
        }
      ],
  "filter": [...]
    }
  }
}
{ "index": "users" }
{
  "query": {
    "bool": {
      "filter": [
        {
          "terms": {
            "_id": liked
          }
        }
      ]
    }
  }
}

```

And then I mix them in code. I'd like to know whether it's somehow possible to avoid using msearch and do this is single query while preserving ratio -- 1/5 from second query and 4/5 from first one?

---

<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:** [April 14, 2020, 5:05pm UTC](https://discuss.elastic.co/t/proportionally-mix-results-from-two-different-searches-on-same-index/223976/2 "2020-04-14T17:05:39Z")

</div>

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