Nested issue for Java api (in urgency)!

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 !!!

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

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

Read this and specifically the "Also be patient" part.

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