13

For example, if something has a higher favorites_count I want it to be more relevant, or if it is updated more recently it is more relevant. Is there a way to do this? This is different than the standard boost functionality, because these fields don't contain keywords, they contain a numeric value.

quinn
  • 5,508
  • 10
  • 34
  • 54
  • 1
    Similar question answered in: http://stackoverflow.com/questions/12091365/is-it-possible-to-boost-newest-items-using-elasticsearch-foqelasticabundle – Pankaj Garg Feb 16 '15 at 19:32

1 Answers1

23

You can use function_score to boost your doc base on a custom formula. Refer here (script_score section) for more details: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

You can also use decay functions to boost recently created documents over older results, refer here for sample: https://www.elastic.co/blog/0-90-4-released/

Then refer here for a more complex sample of using script to calculate score: http://web.archive.org/web/20170107105531/https://jontai.me/blog/2013/01/advanced-scoring-in-elasticsearch/

nnov
  • 489
  • 6
  • 14
Duc.Duong
  • 2,770
  • 2
  • 23
  • 28