# Exception when creating a \_parent mapping in an index that exists, on a type that exists, with no existing \_parent mapping

**URL:** https://discuss.elastic.co/t/exception-when-creating-a--parent-mapping-in-an-index-that-exists-on-a-type-that-exists-with-no-existing--parent-mapping/21870
**Category:** Elasticsearch
**Created:** [January 28, 2015, 8:57am UTC](https://discuss.elastic.co/t/exception-when-creating-a--parent-mapping-in-an-index-that-exists-on-a-type-that-exists-with-no-existing--parent-mapping/21870 "2015-01-28T08:57:54Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Ian\_Boston](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_boston/32/954_2.png) [@Ian\_Boston](https://discuss.elastic.co/u/Ian_Boston)
#### Post date: [January 28, 2015, 8:57am UTC](https://discuss.elastic.co/t/exception-when-creating-a--parent-mapping-in-an-index-that-exists-on-a-type-that-exists-with-no-existing--parent-mapping/21870/1 "2015-01-28T08:57:54Z")

</div>

Hi,

I am trying to add \_parent to a type in an index that already exists using.

```
   PutMappingResponse create = client.admin().indices().preparePutMapping(index).setType(type).setSource("_parent", "type="+parentType).get();

```

The type exists, due to earlier indexing operations, but the \_parent field  
does not.  
The error reported is

org.elasticsearch.index.mapper.MergeMappingException: Merge failed with failures {[The \_parent field's type option can't be changed]}  
at org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:511)  
at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:329)  
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:153)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:744)

This is triggered by the check at [1] which may not be considering the case  
where no \_parent field exists on a type. I understand that its not  
possible to change the type of a \_parent, documents created before a  
\_parent was added will be missing from \_parent queries, but since its not  
possible to index a document with a parent, before the \_parent exists, that  
is not a concern.

Having written a battery of unit tests to find out what worked and what did  
not, I read the source code and opened a bug [2], which was closed telling  
me I was doing it wrong and I needed to ask the list.

My question:  
Am I trying to add the \_parent mapping correctly?  
If I am doing this correctly, is it a bug or the code working as intended  
and the only way to add a \_parent once an type within an index is created  
is to drop the index and reindex. ?

Best Regards  
Ian

1  
[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/28472b95-c0c8-4190-a5dd-908a437229ff%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/28472b95-c0c8-4190-a5dd-908a437229ff%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Ian\_Boston](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_boston/32/954_2.png) [@Ian\_Boston](https://discuss.elastic.co/u/Ian_Boston)
#### Post date: [January 28, 2015, 9:29am UTC](https://discuss.elastic.co/t/exception-when-creating-a--parent-mapping-in-an-index-that-exists-on-a-type-that-exists-with-no-existing--parent-mapping/21870/2 "2015-01-28T09:29:59Z")

</div>

On Wednesday, 28 January 2015 08:57:54 UTC, Ian Boston wrote:

> Hi,
> 
> I am trying to add \_parent to a type in an index that already exists  
> using.
> 
> ```
> PutMappingResponse create = client.admin().indices().preparePutMapping(index).setType(type).setSource("_parent", "type="+parentType).get();
> 
> ```
> 
> The type exists, due to earlier indexing operations, but the \_parent field  
> does not.  
> The error reported is
> 
> org.elasticsearch.index.mapper.MergeMappingException: Merge failed with failures {[The \_parent field's type option can't be changed]}  
> at org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:511)  
> at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:329)  
> at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:153)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:744)
> 
> This is triggered by the check at [1] which may not be considering the  
> case where no \_parent field exists on a type. I understand that its not  
> possible to change the type of a \_parent, documents created before a  
> \_parent was added will be missing from \_parent queries, but since its not  
> possible to index a document with a parent, before the \_parent exists, that  
> is not a concern.
> 
> Having written a battery of unit tests to find out what worked and what  
> did not, I read the source code and opened a bug [2], which was closed  
> telling me I was doing it wrong and I needed to ask the list.
> 
> My question:  
> Am I trying to add the \_parent mapping correctly?  
> If I am doing this correctly, is it a bug or the code working as intended  
> and the only way to add a \_parent once an type within an index is created  
> is to drop the index and reindex. ?
> 
> Best Regards  
> Ian
> 
> 1  
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372)
> 
> Forgot the bug link, sorry.

2 [Unable to update a \_parent mapping for a type in an index once the index exists, even if no \_parent mapping is present for the type. · Issue #9448 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9448)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 28, 2015, 9:36am UTC](https://discuss.elastic.co/t/exception-when-creating-a--parent-mapping-in-an-index-that-exists-on-a-type-that-exists-with-no-existing--parent-mapping/21870/3 "2015-01-28T09:36:22Z")

</div>

Here is what I wrote about this on the issue:

Indeed. I can reproduce your "issue" using REST. So it's not related to Java API.

DELETE test  
PUT test

PUT /test/\_mapping/parent  
{  
"properties": {}  
}

PUT /test/\_mapping/child  
{  
"properties": {}  
}

PUT /test/\_mapping/child  
{  
"\_parent": {  
"type": "new\_parent"  
}  
}  
Gives:

{  
"error": "MergeMappingException[Merge failed with failures {[The \_parent field's type option can't be changed]}]",  
"status": 400  
}  
This is by design. See here: [https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370](https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370) [https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370](https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370)

BTW if you have no document already you can remove the type.

DELETE test  
PUT test

PUT /test/\_mapping/parent  
{  
"properties": {}  
}

PUT /test/\_mapping/child  
{  
"properties": {}  
}

DELETE test/\_mapping/child

PUT /test/\_mapping/child  
{  
"\_parent": {  
"type": "new\_parent"  
}  
}  
This is working.

Hope this helps

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 28 janv. 2015 à 10:29, Ian Boston [ianboston@gmail.com](mailto:ianboston@gmail.com) a écrit :
> 
> On Wednesday, 28 January 2015 08:57:54 UTC, Ian Boston wrote:  
> Hi,
> 
> I am trying to add \_parent to a type in an index that already exists using.
> 
> ```
> PutMappingResponse create = client.admin().indices().preparePutMapping(index).setType(type).setSource("_parent", "type="+parentType).get();
> 
> ```
> 
> The type exists, due to earlier indexing operations, but the \_parent field does not.  
> The error reported is
> 
> org.elasticsearch.index.mapper.MergeMappingException: Merge failed with failures {[The \_parent field's type option can't be changed]}  
> at org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:511)  
> at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:329)  
> at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:153)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:744)
> 
> This is triggered by the check at [1] which may not be considering the case where no \_parent field exists on a type. I understand that its not possible to change the type of a \_parent, documents created before a \_parent was added will be missing from \_parent queries, but since its not possible to index a document with a parent, before the \_parent exists, that is not a concern.
> 
> Having written a battery of unit tests to find out what worked and what did not, I read the source code and opened a bug [2], which was closed telling me I was doing it wrong and I needed to ask the list.
> 
> My question:  
> Am I trying to add the \_parent mapping correctly?  
> If I am doing this correctly, is it a bug or the code working as intended and the only way to add a \_parent once an type within an index is created is to drop the index and reindex. ?
> 
> Best Regards  
> Ian
> 
> 1 [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372) [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372)
> 
> Forgot the bug link, sorry.
> 
> 2 [Unable to update a \_parent mapping for a type in an index once the index exists, even if no \_parent mapping is present for the type. · Issue #9448 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9448) [https://github.com/elasticsearch/elasticsearch/issues/9448](https://github.com/elasticsearch/elasticsearch/issues/9448)
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/781810F2-BC9F-44A0-ABC1-F1E51D725F07%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/781810F2-BC9F-44A0-ABC1-F1E51D725F07%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Ian\_Boston](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_boston/32/954_2.png) [@Ian\_Boston](https://discuss.elastic.co/u/Ian_Boston)
#### Post date: [January 28, 2015, 10:56am UTC](https://discuss.elastic.co/t/exception-when-creating-a--parent-mapping-in-an-index-that-exists-on-a-type-that-exists-with-no-existing--parent-mapping/21870/4 "2015-01-28T10:56:46Z")

</div>

Hi,  
Thanks for the clarification.

How do others do DevOps style updates to Elastic Search based deployments,  
where the updates evolve the index ?

Is the advice to avoid the \_parent feature completely ?

Are there other mappings that behave in the same way that I should be aware  
of ?

The size and realtime nature of both the data set and application I am  
dealing with prohibits dropping an index without taking the application  
offline.... and that would instantly break all SLA's.

Best Regards  
Ian

On Wednesday, 28 January 2015 09:36:32 UTC, David Pilato wrote:

> Here is what I wrote about this on the issue:
> 
> Indeed. I can reproduce your "issue" using REST. So it's not related to  
> Java API.
> 
> DELETE test  
> PUT test
> 
> PUT /test/\_mapping/parent  
> {  
> "properties": {}  
> }
> 
> PUT /test/\_mapping/child  
> {  
> "properties": {}  
> }
> 
> PUT /test/\_mapping/child  
> {  
> "\_parent": {  
> "type": "new\_parent"  
> }  
> }
> 
> Gives:
> 
> {  
> "error": "MergeMappingException[Merge failed with failures {[The \_parent field's type option can't be changed]}]",  
> "status": 400  
> }
> 
> This is by design. See here:  
> [https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370](https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370)
> 
> BTW if you have no document already you can remove the type.
> 
> DELETE test  
> PUT test
> 
> PUT /test/\_mapping/parent  
> {  
> "properties": {}  
> }
> 
> PUT /test/\_mapping/child  
> {  
> "properties": {}  
> }
> 
> DELETE test/\_mapping/child
> 
> PUT /test/\_mapping/child  
> {  
> "\_parent": {  
> "type": "new\_parent"  
> }  
> }
> 
> This is working.
> 
> Hope this helps
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)  
> [http://Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs  
> [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 28 janv. 2015 à 10:29, Ian Boston \<[ianb...@gmail.com](mailto:ianb...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> On Wednesday, 28 January 2015 08:57:54 UTC, Ian Boston wrote:
> 
> > Hi,
> > 
> > I am trying to add \_parent to a type in an index that already exists  
> > using.
> > 
> > ```
> > PutMappingResponse create = client.admin().indices().preparePutMapping(index).setType(type).setSource("_parent", "type="+parentType).get();
> > 
> > ```
> > 
> > The type exists, due to earlier indexing operations, but the \_parent  
> > field does not.  
> > The error reported is
> > 
> > org.elasticsearch.index.mapper.MergeMappingException: Merge failed with failures {[The \_parent field's type option can't be changed]}  
> > at org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:511)  
> > at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:329)  
> > at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:153)  
> > at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > at java.lang.Thread.run(Thread.java:744)
> > 
> > This is triggered by the check at [1] which may not be considering the  
> > case where no \_parent field exists on a type. I understand that its not  
> > possible to change the type of a \_parent, documents created before a  
> > \_parent was added will be missing from \_parent queries, but since its not  
> > possible to index a document with a parent, before the \_parent exists, that  
> > is not a concern.
> > 
> > Having written a battery of unit tests to find out what worked and what  
> > did not, I read the source code and opened a bug [2], which was closed  
> > telling me I was doing it wrong and I needed to ask the list.
> > 
> > My question:  
> > Am I trying to add the \_parent mapping correctly?  
> > If I am doing this correctly, is it a bug or the code working as intended  
> > and the only way to add a \_parent once an type within an index is created  
> > is to drop the index and reindex. ?
> > 
> > Best Regards  
> > Ian
> > 
> > 1  
> > [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372)
> > 
> > Forgot the bug link, sorry.
> 
> 2 [Unable to update a \_parent mapping for a type in an index once the index exists, even if no \_parent mapping is present for the type. · Issue #9448 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9448)
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2af1b167-af2c-440e-8c66-d9c49988aa1f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2af1b167-af2c-440e-8c66-d9c49988aa1f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 28, 2015, 11:04am UTC](https://discuss.elastic.co/t/exception-when-creating-a--parent-mapping-in-an-index-that-exists-on-a-type-that-exists-with-no-existing--parent-mapping/21870/5 "2015-01-28T11:04:04Z")

</div>

What you often do in this context is to use alias on top of your index. Then reindex everything in another index with new settings. And switch the alias.  
No downtime.

HTH

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 28 janv. 2015 à 11:56, Ian Boston [ianboston@gmail.com](mailto:ianboston@gmail.com) a écrit :
> 
> Hi,  
> Thanks for the clarification.
> 
> How do others do DevOps style updates to Elastic Search based deployments, where the updates evolve the index ?
> 
> Is the advice to avoid the \_parent feature completely ?
> 
> Are there other mappings that behave in the same way that I should be aware of ?
> 
> The size and realtime nature of both the data set and application I am dealing with prohibits dropping an index without taking the application offline.... and that would instantly break all SLA's.
> 
> Best Regards  
> Ian
> 
> On Wednesday, 28 January 2015 09:36:32 UTC, David Pilato wrote:  
> Here is what I wrote about this on the issue:
> 
> Indeed. I can reproduce your "issue" using REST. So it's not related to Java API.
> 
> DELETE test  
> PUT test
> 
> PUT /test/\_mapping/parent  
> {  
> "properties": {}  
> }
> 
> PUT /test/\_mapping/child  
> {  
> "properties": {}  
> }
> 
> PUT /test/\_mapping/child  
> {  
> "\_parent": {  
> "type": "new\_parent"  
> }  
> }  
> Gives:
> 
> {  
> "error": "MergeMappingException[Merge failed with failures {[The \_parent field's type option can't be changed]}]",  
> "status": 400  
> }  
> This is by design. See here: [https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370](https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370) [https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370](https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370)
> 
> BTW if you have no document already you can remove the type.
> 
> DELETE test  
> PUT test
> 
> PUT /test/\_mapping/parent  
> {  
> "properties": {}  
> }
> 
> PUT /test/\_mapping/child  
> {  
> "properties": {}  
> }
> 
> DELETE test/\_mapping/child
> 
> PUT /test/\_mapping/child  
> {  
> "\_parent": {  
> "type": "new\_parent"  
> }  
> }  
> This is working.
> 
> Hope this helps
> 
> --  
> David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com) [http://elasticsearch.com/](http://elasticsearch.com/)  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> > Le 28 janv. 2015 à 10:29, Ian Boston \<ianb...@ \<\>[gmail.com](http://gmail.com) [http://gmail.com/](http://gmail.com/)\> a écrit :
> > 
> > On Wednesday, 28 January 2015 08:57:54 UTC, Ian Boston wrote:  
> > Hi,
> > 
> > I am trying to add \_parent to a type in an index that already exists using.
> > 
> > ```
> > PutMappingResponse create = client.admin().indices().preparePutMapping(index).setType(type).setSource("_parent", "type="+parentType).get();
> > 
> > ```
> > 
> > The type exists, due to earlier indexing operations, but the \_parent field does not.  
> > The error reported is
> > 
> > org.elasticsearch.index.mapper.MergeMappingException: Merge failed with failures {[The \_parent field's type option can't be changed]}  
> > at org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:511)  
> > at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:329)  
> > at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:153)  
> > at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > at java.lang.Thread.run(Thread.java:744)
> > 
> > This is triggered by the check at [1] which may not be considering the case where no \_parent field exists on a type. I understand that its not possible to change the type of a \_parent, documents created before a \_parent was added will be missing from \_parent queries, but since its not possible to index a document with a parent, before the \_parent exists, that is not a concern.
> > 
> > Having written a battery of unit tests to find out what worked and what did not, I read the source code and opened a bug [2], which was closed telling me I was doing it wrong and I needed to ask the list.
> > 
> > My question:  
> > Am I trying to add the \_parent mapping correctly?  
> > If I am doing this correctly, is it a bug or the code working as intended and the only way to add a \_parent once an type within an index is created is to drop the index and reindex. ?
> > 
> > Best Regards  
> > Ian
> > 
> > 1 [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372) [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372)
> > 
> > Forgot the bug link, sorry.
> > 
> > 2 [Unable to update a \_parent mapping for a type in an index once the index exists, even if no \_parent mapping is present for the type. · Issue #9448 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9448) [https://github.com/elasticsearch/elasticsearch/issues/9448](https://github.com/elasticsearch/elasticsearch/issues/9448)
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@ \<\>[googlegroups.com](http://googlegroups.com) [http://googlegroups.com/](http://googlegroups.com/).  
> > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com?utm_medium=email&utm_source=footer).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2af1b167-af2c-440e-8c66-d9c49988aa1f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2af1b167-af2c-440e-8c66-d9c49988aa1f%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/2af1b167-af2c-440e-8c66-d9c49988aa1f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2af1b167-af2c-440e-8c66-d9c49988aa1f%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/AC9FD4D8-C0AC-460E-8ECD-59FD8DB074BB%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/AC9FD4D8-C0AC-460E-8ECD-59FD8DB074BB%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Ian\_Boston\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_boston_2/32/954_2.png) [@Ian\_Boston\_2](https://discuss.elastic.co/u/Ian_Boston_2)
#### Post date: [January 28, 2015, 11:09am UTC](https://discuss.elastic.co/t/exception-when-creating-a--parent-mapping-in-an-index-that-exists-on-a-type-that-exists-with-no-existing--parent-mapping/21870/6 "2015-01-28T11:09:00Z")

</div>

Hi,  
Perfect, thanks.  
Best Regards  
Ian

On 28 January 2015 at 11:04, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> What you often do in this context is to use alias on top of your index. Then  
> reindex everything in another index with new settings. And switch the alias.  
> No downtime.
> 
> HTH
> 
> --  
> David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
> @dadoonet | @elasticsearchfr | @scrutmydocs
> 
> Le 28 janv. 2015 à 11:56, Ian Boston [ianboston@gmail.com](mailto:ianboston@gmail.com) a écrit :
> 
> Hi,  
> Thanks for the clarification.
> 
> How do others do DevOps style updates to Elastic Search based deployments,  
> where the updates evolve the index ?
> 
> Is the advice to avoid the \_parent feature completely ?
> 
> Are there other mappings that behave in the same way that I should be aware  
> of ?
> 
> The size and realtime nature of both the data set and application I am  
> dealing with prohibits dropping an index without taking the application  
> offline.... and that would instantly break all SLA's.
> 
> Best Regards  
> Ian
> 
> On Wednesday, 28 January 2015 09:36:32 UTC, David Pilato wrote:
> 
> > Here is what I wrote about this on the issue:
> > 
> > Indeed. I can reproduce your "issue" using REST. So it's not related to  
> > Java API.
> > 
> > DELETE test  
> > PUT test
> > 
> > PUT /test/\_mapping/parent  
> > {  
> > "properties": {}  
> > }
> > 
> > PUT /test/\_mapping/child  
> > {  
> > "properties": {}  
> > }
> > 
> > PUT /test/\_mapping/child  
> > {  
> > "\_parent": {  
> > "type": "new\_parent"  
> > }  
> > }
> > 
> > Gives:
> > 
> > {  
> > "error": "MergeMappingException[Merge failed with failures {[The  
> > \_parent field's type option can't be changed]}]",  
> > "status": 400  
> > }
> > 
> > This is by design. See here:  
> > [https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370](https://github.com/elasticsearch/elasticsearch/blob/1.4/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L367-370)
> > 
> > BTW if you have no document already you can remove the type.
> > 
> > DELETE test  
> > PUT test
> > 
> > PUT /test/\_mapping/parent  
> > {  
> > "properties": {}  
> > }
> > 
> > PUT /test/\_mapping/child  
> > {  
> > "properties": {}  
> > }
> > 
> > DELETE test/\_mapping/child
> > 
> > PUT /test/\_mapping/child  
> > {  
> > "\_parent": {  
> > "type": "new\_parent"  
> > }  
> > }
> > 
> > This is working.
> > 
> > Hope this helps
> > 
> > --  
> > David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
> > @dadoonet | @elasticsearchfr | @scrutmydocs
> > 
> > Le 28 janv. 2015 à 10:29, Ian Boston [ianb...@gmail.com](mailto:ianb...@gmail.com) a écrit :
> > 
> > On Wednesday, 28 January 2015 08:57:54 UTC, Ian Boston wrote:
> > 
> > > Hi,
> > > 
> > > I am trying to add \_parent to a type in an index that already exists  
> > > using.
> > > 
> > > ```
> > > PutMappingResponse create =
> > > 
> > > ```
> > > 
> > > client.admin().indices().preparePutMapping(index).setType(type).setSource("\_parent",  
> > > "type="+parentType).get();
> > > 
> > > The type exists, due to earlier indexing operations, but the \_parent  
> > > field does not.  
> > > The error reported is
> > > 
> > > org.elasticsearch.index.mapper.MergeMappingException: Merge failed with  
> > > failures {[The \_parent field's type option can't be changed]}  
> > > at  
> > > org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:511)  
> > > at  
> > > org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:329)  
> > > at  
> > > org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:153)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > > at java.lang.Thread.run(Thread.java:744)
> > > 
> > > This is triggered by the check at [1] which may not be considering the  
> > > case where no \_parent field exists on a type. I understand that its not  
> > > possible to change the type of a \_parent, documents created before a \_parent  
> > > was added will be missing from \_parent queries, but since its not possible  
> > > to index a document with a parent, before the \_parent exists, that is not a  
> > > concern.
> > > 
> > > Having written a battery of unit tests to find out what worked and what  
> > > did not, I read the source code and opened a bug [2], which was closed  
> > > telling me I was doing it wrong and I needed to ask the list.
> > > 
> > > My question:  
> > > Am I trying to add the \_parent mapping correctly?  
> > > If I am doing this correctly, is it a bug or the code working as intended  
> > > and the only way to add a \_parent once an type within an index is created is  
> > > to drop the index and reindex. ?
> > > 
> > > Best Regards  
> > > Ian
> > > 
> > > 1  
> > > [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java#L372)
> > 
> > Forgot the bug link, sorry.
> > 
> > 2 [Unable to update a \_parent mapping for a type in an index once the index exists, even if no \_parent mapping is present for the type. · Issue #9448 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9448)
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bbb9d2c0-3eb1-4afc-a0f5-62af0e443ca1%40googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/2af1b167-af2c-440e-8c66-d9c49988aa1f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2af1b167-af2c-440e-8c66-d9c49988aa1f%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/rHYGOcwTXPU/unsubscribe](https://groups.google.com/d/topic/elasticsearch/rHYGOcwTXPU/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/AC9FD4D8-C0AC-460E-8ECD-59FD8DB074BB%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/AC9FD4D8-C0AC-460E-8ECD-59FD8DB074BB%40pilato.fr).
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAH%3DGj-mO%2Bte36%3DCUxf65jha6scUatRsiczcKLjO43-Yj4P0rkg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAH%3DGj-mO%2Bte36%3DCUxf65jha6scUatRsiczcKLjO43-Yj4P0rkg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:36am UTC](https://discuss.elastic.co/t/exception-when-creating-a--parent-mapping-in-an-index-that-exists-on-a-type-that-exists-with-no-existing--parent-mapping/21870/7 "2017-07-06T00:36:12Z")

</div>


