# Mapping for Nested Index

**URL:** <https://discuss.elastic.co/t/mapping-for-nested-index/72965>\
**Category:** Elasticsearch\
**Created:** [January 27, 2017, 12:48am UTC](https://discuss.elastic.co/t/mapping-for-nested-index/72965 "2017-01-27T00:48:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![httpex](https://avatars.discourse-cdn.com/v4/letter/h/47e85d/32.png) [@httpex](https://discuss.elastic.co/u/httpex)\
**Post date:** [January 27, 2017, 12:48am UTC](https://discuss.elastic.co/t/mapping-for-nested-index/72965/1 "2017-01-27T00:48:53Z")

</div>

I have a large (481k lines) json document with nested arrays of objects. Here's an example:

# "ICD10CM.index": { "version": "2017", "title": "ICD-10-CM INDEX TO DISEASES and INJURIES", "letter": [{ "title": "A", "mainTerm": [ { "title": "Aarskog's syndrome", "code": "Q87.1" }, { "title": "Abandonment", "see": "Maltreatment" }, { "title": { "nemod": "(-astasia) (hysterical)", "text": "Abasia", "toString": [ null] }, "code": "F44.4" }, { "title": { "nemod": "(cystinosis)", "text": "Abderhalden-Kaufmann-Lignac syndrome", "toString": [null] }, "code": "E72.04" }

To get it to index, do I first have to manually create the mapping of this entire document using "type":"nested"?

e.g.,  
{  
"mappings": {  
"blahblah": {  
"properties": {  
"ICD10CM.index": {  
"type": "string",  
"version": {  
"type": "string"  
},  
"title": {  
"type": "string"  
},  
"letter": {  
"type": "nested",  
"title": {  
"type": "string"  
},  
"mainterm": {  
"type": "nested"  
"title": {  
"type": "string",  
},  
"code": {  
"type": "string"  
},  
"title": {  
"type": "string"  
},  
"see": {  
"type": "string"  
},  
"title": {  
"type": "nested",  
"nemod"  
}  
}  
}  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 29, 2017, 8:44am UTC](https://discuss.elastic.co/t/mapping-for-nested-index/72965/2 "2017-01-29T08:44:41Z")

</div>

In your document you have a field 'title', which is mapped both to a string and an object. As each field must be mapped to a single type in an index, you will need to change the structure of this document before indexing it into Elasticsearch.

---

<div class="post-metadata">

**Author:** ![httpex](https://avatars.discourse-cdn.com/v4/letter/h/47e85d/32.png) [@httpex](https://discuss.elastic.co/u/httpex)\
**Post date:** [February 8, 2017, 2:53am UTC](https://discuss.elastic.co/t/mapping-for-nested-index/72965/3 "2017-02-08T02:53:53Z")

</div>

Great catch. Will fix that and try indexing again.

---

<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:** [March 8, 2017, 2:54am UTC](https://discuss.elastic.co/t/mapping-for-nested-index/72965/4 "2017-03-08T02:54:13Z")

</div>

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