# How to retrieve recursive values in scripted field

**URL:** <https://discuss.elastic.co/t/how-to-retrieve-recursive-values-in-scripted-field/126589>\
**Category:** Kibana\
**Created:** [April 3, 2018, 2:09pm UTC](https://discuss.elastic.co/t/how-to-retrieve-recursive-values-in-scripted-field/126589 "2018-04-03T14:09:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fxolivieri](https://avatars.discourse-cdn.com/v4/letter/f/dec6dc/32.png) [@fxolivieri](https://discuss.elastic.co/u/fxolivieri)\
**Post date:** [April 3, 2018, 2:09pm UTC](https://discuss.elastic.co/t/how-to-retrieve-recursive-values-in-scripted-field/126589/1 "2018-04-03T14:09:45Z")

</div>

Hi !  
I work on a professional project with Kibana V5. I use mainly the Painless language with of scripted fields. In scripted fields, I use the "doc['field.keyword'].value" method to retrieve the value. In this project , there are many recursive fields. So several values that I retrieve.  
In some cases, there are many recursive values but with the "doc['SgmStatus.keyword']" method , I can only get 1 value.  
For example :  
Display kibana discover :  
result field : SgmStatus (SS , SS, SS)  
result scripted fields : SgmStatus (SS)  
The doc['SgmStatus.keyword'].length method return "1" while there are "3".

here is a displayed example :  
SgmStatus (field)  
FieldStatusResultat (Scripted fields)

![ErrorFieldsKibana](https://us1.discourse-cdn.com/elastic/original/3X/7/6/76de94c47b2edb223fe3eea67ea63de647f00b0f.png)

 ![ErrorFieldsKibana2](https://us1.discourse-cdn.com/elastic/original/3X/4/2/422f6d1159d82dfcc0d98056e87fb18070274e99.png)

How to retrieve recursive values in scripted field please ?  
I will need a solution in "the scripted field" to get all the values of the "SgmStatus" recursive field even if the values are identical.  
thanks in advance !!!

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [April 9, 2018, 9:39pm UTC](https://discuss.elastic.co/t/how-to-retrieve-recursive-values-in-scripted-field/126589/2 "2018-04-09T21:39:28Z")

</div>

Hi,

I created a scripted field on a field of array and length is working for me. Can you please check your json and see if your field looks like this?

```auto
"fields": {
    "relatedContent.article:modified_time": [
      "2014-11-26T02:52:51.000Z",
      "2014-11-27T18:29:24.000Z"
    ],

```

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![fxolivieri](https://avatars.discourse-cdn.com/v4/letter/f/dec6dc/32.png) [@fxolivieri](https://discuss.elastic.co/u/fxolivieri)\
**Post date:** [April 10, 2018, 7:43am UTC](https://discuss.elastic.co/t/how-to-retrieve-recursive-values-in-scripted-field/126589/3 "2018-04-10T07:43:16Z")

</div>

Hi,

Thank you for your help. The json field looks like that :

 ![exJsonField](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1a7664a337cbf01f71506e192ca80928bd63f3ef.png)

how is it that if I call the: " doc ['SgmStatus.keyword']. length; " method, I have a return equal to 1?

Thanks,  
François

---

<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:** [May 8, 2018, 7:43am UTC](https://discuss.elastic.co/t/how-to-retrieve-recursive-values-in-scripted-field/126589/4 "2018-05-08T07:43:57Z")

</div>

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