# Runtime field scoring with decay

**URL:** <https://discuss.elastic.co/t/runtime-field-scoring-with-decay/303836>\
**Category:** Elasticsearch\
**Tags:** runtime-fields\
**Created:** [May 3, 2022, 1:13pm UTC](https://discuss.elastic.co/t/runtime-field-scoring-with-decay/303836 "2022-05-03T13:13:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikas\_Verma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikas_verma/32/105170_2.png) [@Vikas\_Verma](https://discuss.elastic.co/u/Vikas_Verma)\
**Post date:** [May 3, 2022, 1:13pm UTC](https://discuss.elastic.co/t/runtime-field-scoring-with-decay/303836/1 "2022-05-03T13:13:53Z")

</div>

Hi,

I've been facing an issue regarding runtime fields scoring using decay functions. Let me share a snippet of my code for the refrence:

**Runtime Field**

```auto
"runtime_mappings": {
        "price": {
            "type": "double",
            "script": {
                "source":''
            }
         }
    }

```

And this is a decay function for score calculation:

```auto
"functions": [
                {
                    "linear": {
                        "price": {
                            "origin": "150.00",
                            "scale": 10,
                            "offset": "50.00",
                            "decay": 0.75
                        }
                    }
                }
            ],

```

Now the thing is, when I search price:

```auto
"must": [
                        {
                            "range": {
                                "price": {
                                    "gte": "100.00",
                                    "lte": "200.00"
                                }
                            }
                        }
                    ]

```

It gives me an error that

```auto
UnhandledPromiseRejectionWarning: Error: [parsing_exception] field [price] is of type [org.elasticsearch.index.mapper.DoubleScriptFieldType@74647e76], but only numeric types are supported., with { line=1 & col=1 }

```

Can anyone help me in this. Because I find that there is an incompatibility of datatypes. How can we handle this issue ?

Thanks in Advance.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 3, 2022, 2:16pm UTC](https://discuss.elastic.co/t/runtime-field-scoring-with-decay/303836/2 "2022-05-03T14:16:23Z")

</div>

wild guess here: maybe putting the `gte` and `lte` values in quotes instead of using numbers is the issue here.

Otherwise, please provide a fully reproducible issue, otherwise it is hard to put the things together in the same way you did.

Thanks!

---

<div class="post-metadata">

**Author:** ![Vikas\_Verma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikas_verma/32/105170_2.png) [@Vikas\_Verma](https://discuss.elastic.co/u/Vikas_Verma)\
**Post date:** [May 4, 2022, 9:19am UTC](https://discuss.elastic.co/t/runtime-field-scoring-with-decay/303836/3 "2022-05-04T09:19:34Z")

</div>

Hi @spinscale, Firstly thanks for taking a time to look into the issue. What other details you want to reproduce the issue ?

---

<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:** [June 1, 2022, 9:20am UTC](https://discuss.elastic.co/t/runtime-field-scoring-with-decay/303836/4 "2022-06-01T09:20:15Z")

</div>

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