# ElasticSearch Nested Object Mapping

**URL:** <https://discuss.elastic.co/t/elasticsearch-nested-object-mapping/59794>\
**Category:** Elasticsearch\
**Created:** [September 5, 2016, 9:41am UTC](https://discuss.elastic.co/t/elasticsearch-nested-object-mapping/59794 "2016-09-05T09:41:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nitin\_Vats1](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@Nitin\_Vats1](https://discuss.elastic.co/u/Nitin_Vats1)\
**Post date:** [September 5, 2016, 9:41am UTC](https://discuss.elastic.co/t/elasticsearch-nested-object-mapping/59794/1 "2016-09-05T09:41:44Z")

</div>

I have created following mapping for in ElasticSearch and same is created. But when I add documents to this type, my nested field type changes to normal. So when I execute query on nested object fields,it shows unexpected results while on rest of the fields results are as expected. I am not sure what I am doing wrong. There must be something I am missing while creating nested object mapping.

{  
"li-new": {

"settings":{  
"index":{  
"analysis":{  
"analyzer":{  
"standard":{  
"tokenizer":"standard",  
"filter":["lowercase","stop"]  
}  
}  
}  
}  
},

```
"mappings": {

```

"\_source" : {  
"enabled" : true  
},  
"\_all": {  
"enabled": false  
},  
"user": {  
"properties": {  
"cityId": {  
"type": "long"  
},  
"country": {  
"type": "string",  
"index":"not\_analysed"  
},  
"emailId": {  
"type": "string",  
"index":"not\_analysed"  
},  
"employmentDetail": {  
"type": "nested",  
"properties": {  
"companyName": {  
"type": "string",  
"index":"not\_analysed"  
},  
"designation": {  
"type": "string",  
"index":"not\_analysed"  
},  
"durationEndMonth": {  
"type": "long"  
},  
"durationEndYear": {  
"type": "long"  
},  
"durationStartMonth": {  
"type": "long"  
},  
"jobProfile": {  
"type": "string"  
},  
"location": {  
"type": "string",  
"index":"not\_analysed"  
}  
}  
},  
"examscores": {  
"type": "nested",  
"properties": {  
"attemptedCount": {  
"type": "long",  
"store" : "yes"  
},  
"candidateId": {  
"type": "long",  
"store" : "yes"  
},  
"examDate": {  
"type": "date",  
"format": "strict\_date\_optional\_time||epoch\_millis"  
},  
"examId": {  
"type": "long",  
"store" : "yes"  
},  
"examScoreDetailId": {  
"type": "long"  
},  
"examTotalScore": {  
"type": "double",  
"store" : "yes"  
},  
"examType": {  
"type": "long"  
},  
"katExamEventId": {  
"type": "long",  
"store" : "yes"  
},  
"rightAttempted": {  
"type": "long"  
},  
"scorePercent": {  
"type": "double",  
"store" : "yes"  
},  
"totalScore": {  
"type": "double"  
}  
}  
},  
"firstName": {  
"type": "string"  
},  
"projectdetail": {  
"type": "nested",  
"properties": {  
"clientName": {  
"type": "string",  
"index":"not\_analysed"  
},  
"designation": {  
"type": "string",  
"index":"not\_analysed"  
}  
},  
"id": {  
"type": "long"  
},  
"location": {  
"type": "string",  
"index":"not\_analysed"  
},  
"title": {  
"type": "string"  
},  
"userId": {  
"type": "long"  
}  
}  
},  
"qualification": {  
"type": "nested",  
"properties": {  
"id": {  
"type": "long"  
},  
"institute": {  
"type": "string",  
"index":"not\_analysed"  
},  
"isPrimary": {  
"type": "long"  
},  
"passingYear": {  
"type": "long"  
}  
}  
},  
"stateId": {  
"type": "long"  
},  
"userId": {  
"type": "long",  
"store" : "yes"  
},  
"uuid": {  
"type": "string",  
"store" : "yes",  
"index":"not\_analysed"  
} }  
}  
}  
}  
}  
}

---

<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 5, 2017, 10:22pm UTC](https://discuss.elastic.co/t/elasticsearch-nested-object-mapping/59794/2 "2017-07-05T22:22:30Z")

</div>


