You can either increase the index time or the query time. I usually prefer to increase the query time, even if it makes the queries a little slower, otherwise I will need to reindex every time I want to change my boost factors, which are usually necessary for fine tuning and should be quite flexible.
There are various ways to apply query time increase using elasticsearch DSL query:
The first three queries are useful if you want to give a specific impulse to documents that match specific queries or filters. For example, if you want to increase only documents published in the last month. You can use this approach with your boosting_field, but you will need to manually determine some boosting_field intervals and give them a different impulse, which is not so great.
The best solution would be to use a Custom Score Query , which will allow you to make a query and configure its score using a script. It is quite powerful, with the help of a script you can directly change the score itself. First of all, I would scale the boosting_field values ββto a value from 0 to 1, for example, so that your final result does not become a large number. To do this, you need to predict what more or less minimum and maximum values ββthat a field can contain. Suppose, for example, a minimum of 0 and a maximum of 100000. If you scale the boosting_field value to a number from 0 to 1, you can add the result to the actual score as follows:
{ "query" : { "custom_score" : { "query" : { "match_all" : {} }, "script" : "_score + (1 * doc.boosting_field.doubleValue / 100000)" } } }
You can also use boosting_field as a boost factor ( _score * , not _score + ), but then you will need to scale it to an interval with a minimum value of 1 (just add +1).
You can even tweak the result to change its value by adding weight to the value you use to influence the score. You will need this even more if you need to combine several enhancement factors together to give them a different weight.
javanna Sep 14 '12 at 19:17 2012-09-14 19:17
source share