# Decay Function question

**URL:** <https://discuss.elastic.co/t/decay-function-question/20615>\
**Category:** Elasticsearch\
**Created:** [November 6, 2014, 7:07pm UTC](https://discuss.elastic.co/t/decay-function-question/20615 "2014-11-06T19:07:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marlo](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@marlo](https://discuss.elastic.co/u/marlo)\
**Post date:** [November 6, 2014, 7:07pm UTC](https://discuss.elastic.co/t/decay-function-question/20615/1 "2014-11-06T19:07:39Z")

</div>

I've begun using the decay function in order to promote more recent results  
in our index. In particular I'm using what's documented here:

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)

Here's the date example they use (let's assume gaussian slope):

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

```

So in trying to visualize this decay, is it safe to make the following  
assumptions in terms of associating these input values to a graph:

- origin is the start (x-value) of the slope, in this case the date  
9/17/2013
- for all points up to offset, the slope is flat, so there's no negative  
scoring for the 5 days after 9/17/2013
- the "end" of the slope is scale
- at the data point 'scale', the slope will have a y-value (on the graph)  
of decay (0.5)

The last point I am not so sure about. Furthermore, I'm unclear as to what  
happens for articles outside of scale, so past 10 days. My test show that  
they actually get a 'zero' multiplier for their score, so basically their  
scores all end up being zero. I was under the impression that they would  
get a score multiplier of 0.5. Any help would be appreciated.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/32d518ad-2b63-4f13-a952-0f408722bd79%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/32d518ad-2b63-4f13-a952-0f408722bd79%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Britta\_Weber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/britta_weber/32/1113_2.png) [@Britta\_Weber](https://discuss.elastic.co/u/Britta_Weber)\
**Post date:** [November 10, 2014, 10:06am UTC](https://discuss.elastic.co/t/decay-function-question/20615/2 "2014-11-10T10:06:42Z")

</div>

Hi Mario,

I added an image which hopefully explains a little better how decay  
functions work here:

> <https://github.com/elastic/elasticsearch/pull/8420/files>

> - origin is the start (x-value) of the slope, in this case the date 9/17/2013

yes

> - for all points up to offset, the slope is flat, so there's no negative scoring for the 5 days after 9/17/2013

The decay function never returns a negative value. It will always be  
between 0 and 1. For each value within +- offset from the defined  
origin the decay function will just return 1.

> - the "end" of the slope is scale

No, decay function will decrease further. The scale parameter just  
steers how quickly the function approaches 0.

- at the data point 'scale', the slope will have a y-value (on the  
graph) of decay (0.5)

yes.

> My test show that they actually get a 'zero' multiplier for their score, so basically their scores all end up being zero. I was under the impression that they would get a score multiplier of 0.5.

No, the score will decrease further until it reaches 0. If you need  
to have documents outside the "scale" range to have a value of 0.5 you  
need to define a separate function which then adjusts the score for  
these documents as needed.

On Thu, Nov 6, 2014 at 8:07 PM, Marlo Epres [mepres@gmail.com](mailto:mepres@gmail.com) wrote:

> I've begun using the decay function in order to promote more recent results  
> in our index. In particular I'm using what's documented here:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)
> 
> Here's the date example they use (let's assume gaussian slope):
> 
> ```
> "DECAY_FUNCTION": {
> "FIELD_NAME": {
> "origin": "2013-09-17",
> "scale": "10d",
> "offset": "5d",
> "decay" : 0.5
> }
> }
> 
> ```
> 
> So in trying to visualize this decay, is it safe to make the following  
> assumptions in terms of associating these input values to a graph:
> 
> - origin is the start (x-value) of the slope, in this case the date  
> 9/17/2013
> - for all points up to offset, the slope is flat, so there's no negative  
> scoring for the 5 days after 9/17/2013
> - the "end" of the slope is scale
> - at the data point 'scale', the slope will have a y-value (on the graph) of  
> decay (0.5)
> 
> The last point I am not so sure about. Furthermore, I'm unclear as to what  
> happens for articles outside of scale, so past 10 days. My test show that  
> they actually get a 'zero' multiplier for their score, so basically their  
> scores all end up being zero. I was under the impression that they would get  
> a score multiplier of 0.5. Any help would be appreciated.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/32d518ad-2b63-4f13-a952-0f408722bd79%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/32d518ad-2b63-4f13-a952-0f408722bd79%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALhJbBimcB2xX49FqyXyXye7ZUrsq3gDPT31gHF0p4%2B3q%2BaXRA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALhJbBimcB2xX49FqyXyXye7ZUrsq3gDPT31gHF0p4%2B3q%2BaXRA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:51am UTC](https://discuss.elastic.co/t/decay-function-question/20615/3 "2017-07-06T00:51:10Z")

</div>


