# Access key value pair from the index using document fields in a script

**URL:** <https://discuss.elastic.co/t/access-key-value-pair-from-the-index-using-document-fields-in-a-script/19515>\
**Category:** Elasticsearch\
**Created:** [August 28, 2014, 5:18pm UTC](https://discuss.elastic.co/t/access-key-value-pair-from-the-index-using-document-fields-in-a-script/19515 "2014-08-28T17:18:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivasan\_Ramaswamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivasan_ramaswamy/32/74106_2.png) [@Srinivasan\_Ramaswamy](https://discuss.elastic.co/u/Srinivasan_Ramaswamy)\
**Post date:** [August 28, 2014, 5:18pm UTC](https://discuss.elastic.co/t/access-key-value-pair-from-the-index-using-document-fields-in-a-script/19515/1 "2014-08-28T17:18:02Z")

</div>

I am trying to access a nested field the form of a map (basically key value  
pairs) using document fields inside a script. But I am only able to get the  
values and not the names Is that possible ? I looked at the code  
for ScriptDocValues and it looks like it supports only four  
types Longs, Doubles, GeoPoints and Strings. Here is the format i am trying  
to get

"nested\_field\_name": {  
"field\_name1": field\_value (number),  
"field\_name2": field\_value (number),  
"field\_name3": field\_value (number)  
}

Is there any way i can access a key value pair using document fields  
(doc[nested\_field\_name] format ) ?

Thanks  
Srini

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c7d5f7db-bca7-453e-a83b-00d1f39b0bca%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c7d5f7db-bca7-453e-a83b-00d1f39b0bca%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:05am UTC](https://discuss.elastic.co/t/access-key-value-pair-from-the-index-using-document-fields-in-a-script/19515/2 "2017-07-06T01:05:44Z")

</div>


