# Cast Long to String

**URL:** <https://discuss.elastic.co/t/cast-long-to-string/148216>\
**Category:** Kibana\
**Created:** [September 11, 2018, 8:30pm UTC](https://discuss.elastic.co/t/cast-long-to-string/148216 "2018-09-11T20:30:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![caub](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/caub/32/33783_2.png) [@caub](https://discuss.elastic.co/u/caub)\
**Post date:** [September 11, 2018, 8:30pm UTC](https://discuss.elastic.co/t/cast-long-to-string/148216/1 "2018-09-11T20:30:03Z")

</div>

I'm getting errors `"cannot convert MethodHandle(Longs)long to (Object)String"`

with this scripts:

```auto
doc['req.method'].value + ' ' + doc['req.path'].value + ' ' + (String)doc['res.status'].value

```

```auto
String s = (String)doc['res.status'].value;
return doc['req.method'].value + ' ' + doc['req.path'].value + ' ' + s

```

```auto
String s = doc['res.status'].value;
return doc['req.method'].value + ' ' + doc['req.path'].value + ' ' + s

```

`req.method` and `req.path` are Strings, `res.status` is a Long

* * *

_note:_

```auto
doc['req.method'].value + ' ' + doc['req.path'].value + ' ' + doc['res.status'].value

```

just silently fails and returns empty value

---

<div class="post-metadata">

**Author:** ![caub](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/caub/32/33783_2.png) [@caub](https://discuss.elastic.co/u/caub)\
**Post date:** [September 11, 2018, 8:50pm UTC](https://discuss.elastic.co/t/cast-long-to-string/148216/2 "2018-09-11T20:50:56Z")

</div>

apparently naming my scripted field with a starting \_ was 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:** [October 9, 2018, 8:51pm UTC](https://discuss.elastic.co/t/cast-long-to-string/148216/3 "2018-10-09T20:51:02Z")

</div>

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