Skip to content

Instantly share code, notes, and snippets.

@kevingessner
Created February 24, 2012 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevingessner/1902998 to your computer and use it in GitHub Desktop.
Save kevingessner/1902998 to your computer and use it in GitHub Desktop.
_routing error with child documents
org.elasticsearch.index.mapper.MapperParsingException: External routing [p1] and document path routing [1] mismatch
at org.elasticsearch.index.mapper.internal.RoutingFieldMapper.validate(RoutingFieldMapper.java:176)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:485)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:417)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:305)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:202)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:529)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:427)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
curl "http://localhost:9200/test/" -XPUT
echo
curl "http://localhost:9200/test/parent/_mapping" -XPUT -d '
{
"parent" : {
"_routing" : {
"required" : true,
"path" : "ixAccount"
},
"properties" : {
"ixAccount" : {
"type" : "integer"
},
"parentData" : {
"type" : "string"
}
}
}
}
'
echo
curl "http://localhost:9200/test/child/_mapping" -XPUT -d '
{
"child" : {
"_parent" : {
"type" : "parent"
},
"_routing" : {
"required" : true,
"path": "ixAccount"
},
"properties" : {
"ixAccount" : {
"type" : "integer"
},
"childData" : {
"type" : "string"
}
}
}
}
'
echo
curl "http://localhost:9200/test/_mapping?pretty"
echo
curl "http://localhost:9200/test/parent/p1" -d '
{
"ixAccount": 1,
"parentData": "parent 1"
}
'
echo
curl "http://localhost:9200/test/parent/p1?pretty"
echo
# this line causes:
# {"error":"MapperParsingException[External routing [p1] and document path routing [1] mismatch]","status":400}
curl "http://localhost:9200/test/child/c1?parent=p1" -d '
{
"ixAccount": 1,
"child": "parent 1"
}
'
echo
curl "http://localhost:9200/test/child/c1?pretty"
echo
# but this works:
curl "http://localhost:9200/test/child/c2?parent=p1&routing=1" -d '
{
"ixAccount": 1,
"child": "parent 1"
}
'
echo
curl "http://localhost:9200/test/child/c2?pretty"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment