# Exception indexing docs having a field with same name as the type

**URL:** <https://discuss.elastic.co/t/exception-indexing-docs-having-a-field-with-same-name-as-the-type/3146>\
**Category:** Elasticsearch\
**Created:** [July 24, 2010, 12:23pm UTC](https://discuss.elastic.co/t/exception-indexing-docs-having-a-field-with-same-name-as-the-type/3146 "2010-07-24T12:23:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergio\_Bossa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergio_bossa/32/3312_2.png) [@Sergio\_Bossa](https://discuss.elastic.co/u/Sergio_Bossa)\
**Post date:** [July 24, 2010, 12:23pm UTC](https://discuss.elastic.co/t/exception-indexing-docs-having-a-field-with-same-name-as-the-type/3146/1 "2010-07-24T12:23:10Z")

</div>

Hi,

I tried to index the following json under the search index and test1 type:

{"test1" : "test1", "test2" : "test2"}

But I get the following exception:

org.elasticsearch.action.support.replication.ReplicationShardOperationFailedException:  
[search][4]  
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:337)  
[elasticsearch-0.8.0.jar:na]  
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.access$400(TransportShardReplicationOperationAction.java:198)  
[elasticsearch-0.8.0.jar:na]  
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:252)  
[elasticsearch-0.8.0.jar:na]  
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
[na:1.6.0\_20]  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
[na:1.6.0\_20]  
at java.lang.Thread.run(Thread.java:637) [na:1.6.0\_20]  
Caused by: org.elasticsearch.index.mapper.MapperException: Malformed  
content, a field with the same name as the type much be an object with  
the properties/fields within it  
at org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:306)  
[elasticsearch-0.8.0.jar:na]  
at org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:272)  
[elasticsearch-0.8.0.jar:na]  
at org.elasticsearch.index.shard.service.InternalIndexShard.innerIndex(InternalIndexShard.java:236)  
[elasticsearch-0.8.0.jar:na]  
at org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:228)  
[elasticsearch-0.8.0.jar:na]  
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:125)  
[elasticsearch-0.8.0.jar:na]  
node.data = true  
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:56)  
[elasticsearch-0.8.0.jar:na]  
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:328)  
[elasticsearch-0.8.0.jar:na]  
... 5 common frames omitted

If I change the type name, or the json content, everything works fine.

Am I missing something or is this an actual bug?  
Thanks!

Sergio B.

--  
Sergio Bossa  
[http://www.linkedin.com/in/sergiob](http://www.linkedin.com/in/sergiob)

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 25, 2010, 8:34am UTC](https://discuss.elastic.co/t/exception-indexing-docs-having-a-field-with-same-name-as-the-type/3146/2 "2010-07-25T08:34:51Z")

</div>

Its not a bug, its a limitation in how elasticsearch works currently. I plan  
to remove it in the future if possible.

-shay.banon

On Sat, Jul 24, 2010 at 3:23 PM, Sergio Bossa [sergio.bossa@gmail.com](mailto:sergio.bossa@gmail.com)wrote:

> Hi,
> 
> I tried to index the following json under the search index and test1 type:
> 
> {"test1" : "test1", "test2" : "test2"}
> 
> But I get the following exception:
> 
> org.elasticsearch.action.support.replication.ReplicationShardOperationFailedException:  
> [search][4]  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:337)  
> [elasticsearch-0.8.0.jar:na]  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.access$400(TransportShardReplicationOperationAction.java:198)  
> [elasticsearch-0.8.0.jar:na]  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:252)  
> [elasticsearch-0.8.0.jar:na]  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> [na:1.6.0\_20]  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> [na:1.6.0\_20]  
> at java.lang.Thread.run(Thread.java:637) [na:1.6.0\_20]  
> Caused by: org.elasticsearch.index.mapper.MapperException: Malformed  
> content, a field with the same name as the type much be an object with  
> the properties/fields within it  
> at  
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:306)  
> [elasticsearch-0.8.0.jar:na]  
> at  
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:272)  
> [elasticsearch-0.8.0.jar:na]  
> at  
> org.elasticsearch.index.shard.service.InternalIndexShard.innerIndex(InternalIndexShard.java:236)  
> [elasticsearch-0.8.0.jar:na]  
> at  
> org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:228)  
> [elasticsearch-0.8.0.jar:na]  
> at  
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:125)  
> [elasticsearch-0.8.0.jar:na]  
> node.data = true  
> at  
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:56)  
> [elasticsearch-0.8.0.jar:na]  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:328)  
> [elasticsearch-0.8.0.jar:na]  
> ... 5 common frames omitted
> 
> If I change the type name, or the json content, everything works fine.
> 
> Am I missing something or is this an actual bug?  
> Thanks!
> 
> Sergio B.
> 
> --  
> Sergio Bossa  
> [http://www.linkedin.com/in/sergiob](http://www.linkedin.com/in/sergiob)

---

<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, 4:21am UTC](https://discuss.elastic.co/t/exception-indexing-docs-having-a-field-with-same-name-as-the-type/3146/3 "2017-07-06T04:21:42Z")

</div>


