# Nested issue for Java api （in urgency）!

**URL:** <https://discuss.elastic.co/t/nested-issue-for-java-api-in-urgency/115443>\
**Category:** Elasticsearch\
**Created:** [January 14, 2018, 12:18pm UTC](https://discuss.elastic.co/t/nested-issue-for-java-api-in-urgency/115443 "2018-01-14T12:18:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![koqiui163](https://avatars.discourse-cdn.com/v4/letter/k/58f4c7/32.png) [@koqiui163](https://discuss.elastic.co/u/koqiui163)\
**Post date:** [January 14, 2018, 12:18pm UTC](https://discuss.elastic.co/t/nested-issue-for-java-api-in-urgency/115443/1 "2018-01-14T12:18:33Z")

</div>

ES version : 2.4.4

We need Nested Query in our business , so I write code as ES doc says, but failed.  
My Doc Mapping coded as the following :  
------------------------ doc mapping --------------------------  
{  
"properties": {  
"name": {  
"type": "string",  
"analyzer": "ik"  
},  
"age": {  
"type": "integer"  
},  
"desc": {  
"type": "string",  
"analyzer": "ik"  
},  
"birthdate": {  
"type": "date",  
"format": "yyyy-MM-dd||yyyy-MM-dd HH:mm:ss"  
},  
"friends": {  
"type": "nested",  
"properties": {  
"name": {  
"type": "string",  
"analyzer": "ik"  
},  
"age": {  
"type": "integer"  
},  
"gender": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}

-------------------------- sample data ---------------------  
[  
//100  
{  
"name": "王思聪",  
"age": 42,  
"desc": "国民老公",  
"keywords": ["国民", "国民老公"],  
"friends": [{  
"name": "王娜",  
"age": 29,  
"gender": "女"  
}, {  
"name": "老李",  
"age": 50,  
"gender": "男"  
},  
{  
"name": "小花",  
"age": 25,  
"gender": "女"  
}  
]  
},  
//200  
{  
"name": "东东",  
"age": 27,  
"desc": "小可爱",  
"birthdate": "1992-12-25",  
"keywords": ["国民", "国民老婆"],  
"friends": [{  
"name": "大花",  
"age": 46,  
"gender": "女"  
},  
{  
"name": "小王",  
"age": 32,  
"gender": "男"  
}  
]  
},  
//300  
{  
"name": "老杨",  
"age": 55,  
"birthdate": "2000-01-13",  
"keywords": ["老男神"],  
"friends": [{  
"name": "小花",  
"age": 25,  
"gender": "女"  
}]  
},  
//400  
{  
"name": "小豹王",  
"age": 35,  
"desc": "野蛮小将军",  
"keywords": ["男神"],  
"friends": [{  
"name": "李斌",  
"age": 32,  
"gender": "男"  
},  
{  
"name": "王娜",  
"age": 29,  
"gender": "女"  
},  
{  
"name": "超杰",  
"age": 36,  
"gender": "男"  
}  
]  
},  
//500  
{  
"name": "光明",  
"age": 23,  
"desc": "我们的宝贝儿",  
"keywords": ["男神", "帅哥"],  
"friends": [{  
"name": "小冰",  
"age": 36,  
"gender": "女"  
},  
{  
"name": "超杰",  
"age": 36,  
"gender": "男"  
}  
]  
}  
]

* * *

I can index ( as well as query ) the doc data with other rest api client， but when I index the data with java api client, it goes wrong, the error message is : cant be changed from nested to Non nested 。

I have tried "dynamic : false/strict” to avoid changing field types, but still not work.

Anyone can figure it out ?

Many thanks !!!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 14, 2018, 1:12pm UTC](https://discuss.elastic.co/t/nested-issue-for-java-api-in-urgency/115443/2 "2018-01-14T13:12:58Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

About "urgency" in the title, it's useless.

Read [this](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and specifically the "Also be patient" part.

---

<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:** [February 11, 2018, 1:13pm UTC](https://discuss.elastic.co/t/nested-issue-for-java-api-in-urgency/115443/3 "2018-02-11T13:13:32Z")

</div>

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