# Runtime field field conversion problem,

**URL:** https://discuss.elastic.co/t/runtime-field-field-conversion-problem/336013
**Category:** Elasticsearch
**Tags:** painless, runtime-fields
**Created:** [June 14, 2023, 9:34pm UTC](https://discuss.elastic.co/t/runtime-field-field-conversion-problem/336013 "2023-06-14T21:34:45Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rexxdad](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rexxdad](https://discuss.elastic.co/u/rexxdad)
#### Post date: [June 14, 2023, 9:34pm UTC](https://discuss.elastic.co/t/runtime-field-field-conversion-problem/336013/1 "2023-06-14T21:34:45Z")

</div>

followup on

> [@Adding added field to index](https://discuss.elastic.co/t/adding-added-field-to-index/335440/13):
>
> thank you for that

I found one other thing, .

when the data is long

""longitude":-99.628611894415343,"latitude":37.463502579397019

the painless script has trouble figuring out what data type it is..

```auto
              "script_stack": [
                "emit(doc['addressinfo.latitude'].value, doc['addressinfo.longitude'].value)}",
                " ^---- HERE"
              ],
              "script": "if(doc.containsKey('addressinfo.latitude')){emit(doc['addressinfo.latitude'].value, doc['addressinfo.longitude'].value)}",
              "lang": "painless",
              "position": {
                "offset": 76,
                "start": 44,
                "end": 120
              },
              "caused_by": {
                "type": "wrong_method_type_exception",
                "reason": "cannot convert MethodHandle(Strings)String to (Object)double"
              }

```

if you change it to explicitly parse, then it works ok..

```auto
"source":
                "if(doc.containsKey('addressinfo.latitude')){emit(Float.parseFloat(doc['addressinfo.latitude'].value), Float.parseFloat(doc['addressinfo.longitude'].value))}"
            }

```

but.. one shouldn't have to do that.. just because the decimal is a long string....

---

<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 12, 2023, 9:35pm UTC](https://discuss.elastic.co/t/runtime-field-field-conversion-problem/336013/2 "2023-07-12T21:35:16Z")

</div>

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