Skip to content

Instantly share code, notes, and snippets.

@christoph-frick
Created March 31, 2014 14:38
Show Gist options
  • Save christoph-frick/9893830 to your computer and use it in GitHub Desktop.
Save christoph-frick/9893830 to your computer and use it in GitHub Desktop.
curl -s -XDELETE localhost:9200/so_delete_parent >/dev/null
curl -s -XPUT localhost:9200/so_delete_parent/ -d '{ "settings": { "index": { "number_of_shards" : 2 } } }' >/dev/null
curl -s -XPUT localhosT:9200/so_delete_parent/childs/_mapping -d '{ "_parent": { "type": "parents" } }' >/dev/null
curl -s -XPUT localhost:9200/so_delete_parent/childs/A\?parent=1 -d '{ "doc": "parent 1" }'
curl -s -XPUT localhost:9200/so_delete_parent/childs/A\?parent=2 -d '{ "doc": "parent 2" }'
curl -s localhost:9200/so_delete_parent/childs/A\?parent=1 | json_pp
curl -s localhost:9200/so_delete_parent/childs/A\?parent=2 | json_pp
curl -s localhost:9200/so_delete_parent/childs/A\?parent=666 | json_pp
curl -s localhost:9200/so_delete_parent/childs/A | json_pp # fails with ES 1.0
results in:
# put parent=1
{"_index":"so_delete_parent","_type":"childs","_id":"A","_version":1,"created":true}
# put parent=2
{"_index":"so_delete_parent","_type":"childs","_id":"A","_version":1,"created":true}
# get parent=1
{
"_source" : {
"doc" : "parent 1"
},
"_index" : "so_delete_parent",
"_id" : "A",
"_type" : "childs",
"found" : true,
"_version" : 1
}
# get parent=2
{
"_source" : {
"doc" : "parent 2"
},
"_index" : "so_delete_parent",
"_id" : "A",
"_type" : "childs",
"found" : true,
"_version" : 1
}
# get parent=666
{
"_source" : {
"doc" : "parent 2"
},
"_index" : "so_delete_parent",
"_id" : "A",
"_type" : "childs",
"found" : true,
"_version" : 1
}
# no parent param -- works with (some?) ES 0.9 versions
{
"status" : 400,
"error" : "RoutingMissingException[routing is required for [so_delete_parent]/[childs]/[A]]"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment