# Index issue returns empty

**URL:** <https://discuss.elastic.co/t/index-issue-returns-empty/196668>\
**Category:** Kibana\
**Tags:** painless\
**Created:** [August 25, 2019, 4:02pm UTC](https://discuss.elastic.co/t/index-issue-returns-empty/196668 "2019-08-25T16:02:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg\_Mercado](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greg_mercado/32/51054_2.png) [@Greg\_Mercado](https://discuss.elastic.co/u/Greg_Mercado)\
**Post date:** [August 25, 2019, 4:02pm UTC](https://discuss.elastic.co/t/index-issue-returns-empty/196668/1 "2019-08-25T16:02:39Z")

</div>

I am trying to create a scripted field that takes a integer status and returns a string status from a list.  
the doc field returns an integer value and the list returns a string when I manually input an integer, but when I try to use the doc field as the index integer it returns an empty list.

```
def stat = ['unknown', 'onLine', 'onBattery', 'onSmartBoost', 'timedSleeping', 'softwareBypass', 'off', 'rebooting', 'switchedBypass', 'hardwareFailureBypass', 'sleepingUntilPowerReturn', 'onSmartTrim'];

```

the array --^

```
stat[doc['iso.org.dod.internet.private.enterprises.318.1.1.1.4.1.1.0'].value -1];

```

Returns

```
[]

```

while

```
stat[3]

```

Returns

```
["onSmartBoost", ...]

```

and

```
doc['iso.org.dod.internet.private.enterprises.318.1.1.1.4.1.1.0'].value -1

```

Returns

```
[3, ...]

```

so my question is if I'm getting integers for the doc and integers work as an index for the list why do I get an empty list?

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [August 25, 2019, 5:00pm UTC](https://discuss.elastic.co/t/index-issue-returns-empty/196668/2 "2019-08-25T17:00:49Z")

</div>

Hey Greg, thanks for your request and welcome to our community.

It can maybe a problem of wrong data type and you should cast to int the value, can you please tell me the mappings for that document value?

> [@Greg\_Mercado](#):
>
> doc['iso.org.dod.internet.private.enterprises.318.1.1.1.4.1.1.0']

---

<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:** [September 22, 2019, 5:00pm UTC](https://discuss.elastic.co/t/index-issue-returns-empty/196668/3 "2019-09-22T17:00:50Z")

</div>

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