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

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

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.comwrote:

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