How to boost relevance using decay functions

In the previous section, we used the number of reviews and the price of the product to compute the relevance score. In this section, we will promote the recent products using their release date. We want to score the most recently released products higher than the older ones. By the end of this section, we will combine the scores from the main search, the number of reviews, and the release date.

We can start by defining range queries for different time intervals and wrap them in a bool query. Assuming that products released last year are less important than those released in the current year, in the following query, products that are released in the current year are boosted by 1, the products released ...

Get Learning Elasticsearch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.