# Way to retrieve the nested data using java

**URL:** <https://discuss.elastic.co/t/way-to-retrieve-the-nested-data-using-java/146543>\
**Category:** Elasticsearch\
**Created:** [August 29, 2018, 2:15pm UTC](https://discuss.elastic.co/t/way-to-retrieve-the-nested-data-using-java/146543 "2018-08-29T14:15:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vivekranjan](https://avatars.discourse-cdn.com/v4/letter/v/7ea924/32.png) [@vivekranjan](https://discuss.elastic.co/u/vivekranjan)\
**Post date:** [August 29, 2018, 2:15pm UTC](https://discuss.elastic.co/t/way-to-retrieve-the-nested-data-using-java/146543/1 "2018-08-29T14:15:18Z")

</div>

Hi all,  
I have a nested data in elasticsearch and i need to retrieve it. Can some one tell me the way to do the same. I have tried all the possible way and either I am getting null in the Postman and tried googling as well but not getting any clue. Here is the code

```
"partydetails": [
                  {
                    "type": "happy",
                    "properties": {
                      "Name": "Rashmi",
                      "Dob": "28-02-1994",
                      "Gender": "female"
                    }
                  },
                 {
                    "type": "sad",
                    "properties": {
                      "Name": "ranchita",
                      "Dob": "28-06-1995",
                      "Gender": "female"
                    }
                  }
                ]

```

I need to extract the Name from this JSON data using java.  
Thanks in advance.

**EDIT** :- I have got the solution from the below mentioned link and now I am able to access them, **but I have one more doubt** ,

`https://stackoverflow.com/questions/33441828/how-to-access-nested-json-in-elasticsearch`

Now, after doing this what I feel is, the field values are hardcoded and if anyone will change the mapping/index\_name or any other field name then the same code will not work. So, is there some way that we can obtain the same dynamically at run time.

**Edit 2:-**  
@dadoonet Please help me.

---

<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 26, 2018, 2:15pm UTC](https://discuss.elastic.co/t/way-to-retrieve-the-nested-data-using-java/146543/2 "2018-09-26T14:15:21Z")

</div>

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