How do i add boosting to the elasticsearch mapping in ONGR?

292 Views Asked by At

I want to boost documents in my ONGR setup. As show here the most efficiant way to do so, is by adding it to the mapping:

"boosting_field": {"type" : "integer", "store" : "yes", "index" : "yes", "boost" : 10.0,}

How can i do that in ONGR?

3

There are 3 best solutions below

0
On

Boosting fields at index time in the mapping is strongly discouraged because once set you can never change the boost of your field. Moreover this feature might even be removed in future versions.

So you should definitely go for query-time boosting, which is a much more flexible way to boost your fields.

3
On

You definitely have to avoid using boost in the index mapping. Instead, in the search try to use field weights. e.g.

{
"query": {
"bool": {
  "should": [
    {
      "term": {
        "title": "acme^2"
      }
    },
    {
      "term": {
        "description": "bar^1"
      }
    }
   ]
  }
 }
}
0
On

If you want to add any custom field to the mapping in this particular case boost, you can do it via options, see the example below:

//...
    /**
     * @ES\Property(type="string", options={"boost"="10"})
     */
    public $title;
//...