Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Decay function and its parameters in ElasticSearch

I was reading about decay functions in ElasticSearch in order to promote more recent results

If I define decay function as following:

"DECAY_FUNCTION": {
    "FIELD_NAME": {
        "origin": "2013-09-17",
        "scale": "10d",
        "offset": "5d",
        "decay": 0.5
    }
}

How the score will be affected within the Offset, Scale regions and outside them?

like image 650
Simple Code Avatar asked Dec 15 '17 13:12

Simple Code


1 Answers

Depending on this reference query-dsl-function-score-query I will answer my question:

Let's take this slope as example:

Decay's Slope

Here the origin is age=40 and we have offset=+-5 years. So the decay function will return value of 1 inside offset [35-45].

Inside Scale the function will return the value of decay(which is in our example 0.5)

The regions outside Scale(which are more than 50 and less than 35), decay function will decrease further towards 0 value.

PS

  • The scale parameter just steers how quickly the function approaches 0
  • The decay function never returns a negative value. It will always be between 0 and 1.
  • There are three types of decay function (gauss, exponential, and linear) and as we noticed in the slope above how each type steers.
like image 122
Simple Code Avatar answered Sep 25 '22 10:09

Simple Code