# Scripted field How to retrieve recursive values

**URL:** <https://discuss.elastic.co/t/scripted-field-how-to-retrieve-recursive-values/126959>\
**Category:** Elasticsearch\
**Created:** [April 5, 2018, 3:23pm UTC](https://discuss.elastic.co/t/scripted-field-how-to-retrieve-recursive-values/126959 "2018-04-05T15:23:22Z")\
**Posts on this page:** 3\
**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 5, 2018, 3:23pm UTC](https://discuss.elastic.co/t/scripted-field-how-to-retrieve-recursive-values/126959/1 "2018-04-05T15:23:22Z")

</div>

Hi !  
I'm working 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'].values" 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:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [April 13, 2018, 2:43pm UTC](https://discuss.elastic.co/t/scripted-field-how-to-retrieve-recursive-values/126959/2 "2018-04-13T14:43:50Z")

</div>

First, just to clarify, by "recursive values" you mean duplicate terms? Lucene dedups these terms in docvalues; there is no way around that. If you want to see how many original terms a field has, I suggest using an ingest processor to index this information into a separate field. Otherwise, your only option would be to use `_source` (which has the original json that was indexed), which is going to be considerably slower to access.

---

<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 11, 2018, 2:43pm UTC](https://discuss.elastic.co/t/scripted-field-how-to-retrieve-recursive-values/126959/3 "2018-05-11T14:43:57Z")

</div>

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