# Add new field to existing nested

**URL:** <https://discuss.elastic.co/t/add-new-field-to-existing-nested/92124>\
**Category:** Elasticsearch\
**Created:** [July 6, 2017, 2:50pm UTC](https://discuss.elastic.co/t/add-new-field-to-existing-nested/92124 "2017-07-06T14:50:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikentyi](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@Vikentyi](https://discuss.elastic.co/u/Vikentyi)\
**Post date:** [July 6, 2017, 2:50pm UTC](https://discuss.elastic.co/t/add-new-field-to-existing-nested/92124/1 "2017-07-06T14:50:37Z")

</div>

Hello.  
I have my index mapping with nested:

{  
"index\_test": {  
"mappings": {  
"search\_type": {  
"properties": {  
"person": {  
"properties": {  
"relation": {  
"properties": {  
"subject": {  
"type": "nested",  
"properties": {  
"firstName": {  
"type": "keyword",  
"fields": {  
"english": {  
"type": "text",  
"analyzer": "english"  
} } },  
"lastName": {  
"type": "keyword",  
"fields": {  
"english": {  
"type": "text",  
"analyzer": "english"  
} } } } } } } } } }} } }

But I want to add new field 'organization' to my nested 'subject'. How should I do it?

I am using Java API:  
/\*  
xContentBuilder.string = {  
"search\_type": {  
"properties": {  
"person.relation.subject.organization": {  
"type": "keyword",  
"fields": {  
"english": {  
"type": "text",  
"analyzer": "english"  
} } } } } }  
\*/  
m\_transportClient.admin().indices()  
.preparePutMapping( "index\_test")  
.setType( "search\_type" )  
.setSource( xContentBuilder ).get();

gives me EXCEPTION: object mapping [person.relation.subject] can't be changed from nested to non-nested

How to add new field for mapping of nested object?

---

<div class="post-metadata">

**Author:** ![Vikentyi](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@Vikentyi](https://discuss.elastic.co/u/Vikentyi)\
**Post date:** [July 6, 2017, 5:14pm UTC](https://discuss.elastic.co/t/add-new-field-to-existing-nested/92124/2 "2017-07-06T17:14:57Z")

</div>

I have found my bug here, so this topic can be deleted. Thank you.

---

<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:** [August 3, 2017, 5:15pm UTC](https://discuss.elastic.co/t/add-new-field-to-existing-nested/92124/3 "2017-08-03T17:15:20Z")

</div>

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