How to define a ratio of values which should be inside the result set of a function score query

Hi ES group,

i have a function score query, which searches for user profiles in a big
pool (~2 million documents). The query works fine, but the index contains a
lot more male profiles than female ones (around 100 times more). Now my
goal is to somehow specify a ratio of the gender distribution of the
result. For example i want to get 6 male and 4 female profiles at any time
I query the index. How could I force ES to ensure this ratio?

I tried a filter on the gender attribute inside the function score query
with a boost_factor but it didn't worked out. The result contains about 9
male and 1 female profile right now.

The query looks like the following (slightly stripped-down):

{
"query": {
"function_score": {
"boost_mode": "replace",
"score_mode": "sum",
"boost": 1,
"filter": {
// some hard filter, this shouldn't matter
},
"functions": [
{
"random_score": {
"seed": null
}
},
{
"boost_factor": 1,
"field_value_factor": {
"field": "gender",
"gender": "female"

      }
    },
    {
      "linear": {
        "location": {
          "origin": "", //some origin here
          "scale": "50km",
          "offset": "25km",
          "decay": 0.25
        }
      }
    },
    {
      "linear": {
        "lastlogin": {
          "origin": "2014-10-14",
          "scale": "30d",
          "offset": "1d",
          "decay": 0.5
        }
      }
    }
  ]
}

},
"from": 0,
"size": 10
}

Best regards,
Stefan

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/237fdee5-3c8f-471e-b8fd-ce53f6b086be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.