# ElasticsearchParseException/NumberFormatException in scale/offset of decay function scoring

**URL:** <https://discuss.elastic.co/t/elasticsearchparseexception-numberformatexception-in-scale-offset-of-decay-function-scoring/1896>\
**Category:** Elasticsearch\
**Created:** [June 4, 2015, 3:23am UTC](https://discuss.elastic.co/t/elasticsearchparseexception-numberformatexception-in-scale-offset-of-decay-function-scoring/1896 "2015-06-04T03:23:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtuck9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dtuck9](https://discuss.elastic.co/u/dtuck9)\
**Post date:** [June 4, 2015, 3:23am UTC](https://discuss.elastic.co/t/elasticsearchparseexception-numberformatexception-in-scale-offset-of-decay-function-scoring/1896/1 "2015-06-04T03:23:54Z")

</div>

Per the documentation for decay functions, I'm using the [Date Format](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html) specified - e.g., 1M for 1 month, 1y for 1 year...

I'm getting parse exceptions due to number format exception except for d for day and w for week. Why is this?

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [June 4, 2015, 10:07am UTC](https://discuss.elastic.co/t/elasticsearchparseexception-numberformatexception-in-scale-offset-of-decay-function-scoring/1896/2 "2015-06-04T10:07:34Z")

</div>

function score query with linear decay function?

[https://github.com/elastic/elasticsearch/blob/master/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreTests.java#L615](https://github.com/elastic/elasticsearch/blob/master/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreTests.java#L615)

what's your query code?

---

<div class="post-metadata">

**Author:** ![dtuck9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dtuck9](https://discuss.elastic.co/u/dtuck9)\
**Post date:** [June 4, 2015, 6:10pm UTC](https://discuss.elastic.co/t/elasticsearchparseexception-numberformatexception-in-scale-offset-of-decay-function-scoring/1896/3 "2015-06-04T18:10:16Z")

</div>

Using exponential decay - code is as follows (we've templated our queries with handlebars), and I'm getting the NumberFormatException on 1.5y (or 1y when I tried that) and 1M - 365d worked and 5w worked, lowercase m worked as well but it's unclear if that's minutes as it should be per the Date Format documentation or if it's months:

```
"exp" : {
        "{{FIELD_UPLOAD_DATE}}" : {
            "scale" : "1.5y",
            "offset" : "1M",
            "decay" : {{recencyDecay}}
        }
    }
```

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [June 6, 2015, 10:14am UTC](https://discuss.elastic.co/t/elasticsearchparseexception-numberformatexception-in-scale-offset-of-decay-function-scoring/1896/4 "2015-06-06T10:14:29Z")

</div>

> **[format | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#date-math)**

> the units supported are y (year), M (month), w (week), d (day), h (hour), m (minute), and s (second).

---

<div class="post-metadata">

**Author:** ![dtuck9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dtuck9](https://discuss.elastic.co/u/dtuck9)\
**Post date:** [June 9, 2015, 11:16pm UTC](https://discuss.elastic.co/t/elasticsearchparseexception-numberformatexception-in-scale-offset-of-decay-function-scoring/1896/5 "2015-06-09T23:16:37Z")

</div>

Thank you for confirming that. However, when I use y or M, I get a NumberFormatException, and I'm running on version 1.4.2:

! ]]]; \*\*nested: ElasticsearchParseException[Failed to parse [1y]]; nested: NumberFormatException

! ]]]; nested: ElasticsearchParseException[Failed to parse [1M]]; nested: NumberFormatException[For input string: "1M"]; }

---

<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:08am UTC](https://discuss.elastic.co/t/elasticsearchparseexception-numberformatexception-in-scale-offset-of-decay-function-scoring/1896/6 "2017-07-06T00:08:45Z")

</div>


