2

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?

Community
  • 1
  • 1
j.krug
  • 21
  • 3

3 Answers3

1

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.

Val
  • 207,596
  • 13
  • 358
  • 360
1

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;
//...
saimaz
  • 301
  • 1
  • 2
  • 8
0

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"
      }
    }
   ]
  }
 }
}
saimaz
  • 301
  • 1
  • 2
  • 8
  • But how if i want to have the boosting value in a special field? – j.krug Mar 03 '16 at 15:14
  • I want to have a int field which contains a pre calculated boosting value that should influence the sorting (not overwrite it). – j.krug Mar 07 '16 at 09:46
  • When you define a document field use options: @ES\Property(type="string", options={"boost"="10"}) – saimaz Mar 15 '16 at 08:19