Is it possible to obtain results with different term queries that each could have a percentage weight?

Does anyone know if it's possible to obtain results to use an alternative term search based on a percentage? For example Imagine I have an Apple index. I'd like to have 40% of the results to be color red while 60% to be color green? I don't think this is possible withminimum_should_match

Maybe something like

{
 "bool": {
          "should": [
            {
              "term": {
                "color": "red"
              },
            "minimum_should_match": 60%
            },
            {
              "term": {
                "color": "green"
              },
            "minimum_should_match": 40%
            }
          ]
        }
}

No, there is no such option. You would need to run 2 queries with colors red and green and desired "size" and combine results on your client side.

One alternative thing you can do is to collapse results based on the "color" field, and get top N inner hits for each color.

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