Add score +30 if doc['someField'].value == "some"

Hello

I have document:
{
"_id": 111
"price": 1000
"color": "red"
}

I'm use function_score with gauss function for get score by price.
Now, i need add +30 score if color == "green". Preferably without use groovy script.
But, if color != "green", then still get this document in result, just without these extra 30 points score.
There are ideas in which direction to look?

Thank you

I'm have solution:

{
  "query": {
    "bool": {
      "should": [
        {
          "match_all": {}
        },
        {
          "constant_score": {
            "filter": {
              "term": {
                "color": "red"
              }
            },
            "boost": 30
          }
        }
      ]
    }
  },
  "sort": {
    "_score": {
      "order": "desc"
    }
  }
}

I've tried this request before, but it returned an incorrect result due to the fact that I used the old version. As soon as I updated from 2 to 6 versions, the problem disappeared

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