# Prevent multiply by zero when using Gauss Decay function

**URL:** <https://discuss.elastic.co/t/prevent-multiply-by-zero-when-using-gauss-decay-function/110010>\
**Category:** Elasticsearch\
**Created:** [December 2, 2017, 3:48pm UTC](https://discuss.elastic.co/t/prevent-multiply-by-zero-when-using-gauss-decay-function/110010 "2017-12-02T15:48:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mortenxd](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@mortenxd](https://discuss.elastic.co/u/mortenxd)\
**Post date:** [December 2, 2017, 3:48pm UTC](https://discuss.elastic.co/t/prevent-multiply-by-zero-when-using-gauss-decay-function/110010/1 "2017-12-02T15:48:46Z")

</div>

Hello,

I'm using a Gauss Decay function to decrease relevance of old documents in my index (origin is current time). Is there a way to prevent a Gauss function to return 0 for very old documents in this case?

I am using a function score query with score mode multiply. For very old documents in my index their relevance is always 0 because of multiplication with 0 from the Gauss Decay function with the current time as the origin. Is there a way to prevent this?

Thanks for your time, I appreciate any feedback 🙂

---

<div class="post-metadata">

**Author:** ![luiz.santos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz.santos/32/24664_2.png) [@luiz.santos](https://discuss.elastic.co/u/luiz.santos)\
**Post date:** [December 8, 2017, 12:50pm UTC](https://discuss.elastic.co/t/prevent-multiply-by-zero-when-using-gauss-decay-function/110010/2 "2017-12-08T12:50:22Z")

</div>

Hi @mortenxd,

Can you check if the parameter boost\_mode works for you?

```
POST posts/doc/1
{
  "date": "1800-12-08T00:00:00"
}

POST posts/doc/2
{
  "date": "2017-12-08T00:00:00"
}

GET posts/_search
{
  "query": {
    "function_score": {
      "boost_mode": "avg",
      "score_mode": "multiply", 
      "gauss": {
        "date": {
          "origin": "2017-12-08T00:00:00",
          "scale": "10d",
          "decay": 0.5
        }
      }
    }
  }
}

```

Cheers,  
LG

---

<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:** [January 5, 2018, 12:50pm UTC](https://discuss.elastic.co/t/prevent-multiply-by-zero-when-using-gauss-decay-function/110010/3 "2018-01-05T12:50:46Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
