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):
/_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?