1
votes

I'm currently using elasticsearch version 2.4 and wish to fine tune my result set based on a field I have called 'type' using query time boosting or weighting.

For example

If the value of the field 'type' is "Boats" add a weighting or boost of 4

If the value of the field 'type' is "Caravans" add a weighting or boost of 3

Thereforfor making boats that matched the query string appear before caravans in the search results.

I've found the documentation I've read so far very convoluted in regards to filters, functions and function scores. I'd appreciate if someone could provide an example to my scenario to get me going.

1
Try the constant_score query - RoiHatam
Thanks, great answer - vybe

1 Answers

0
votes

You should use the constant_score query and the boost option to prioritize.

{
  "query": {
    "bool": {
        "should": [
            {
                "constant_score": {
                    "boost": 4,
                    "query": {
                        "match": {
                            "description": "Boats"
                        }
                    }
                }
            },
            {
                "constant_score": {
                    "boost": 3,
                    "query": {
                        "match": {
                            "description": "Caravans"
                        }
                    }
                }
            }
        ]
    }
  }
}