Skip to content

Instantly share code, notes, and snippets.

@luizgpsantos
Created September 1, 2014 20:16
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 luizgpsantos/031fb36af5545afde29b to your computer and use it in GitHub Desktop.
Save luizgpsantos/031fb36af5545afde29b to your computer and use it in GitHub Desktop.
Update nested document
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test -d '{
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 0
},
"mappings": {
"car": {
"properties": {
"creators" : {
"type": "nested",
"properties": {
"name": {"type":"string"}
}
}
}
}
}
}
'
curl -XPOST localhost:9200/test/car/1 -d '{
"creators": [{
"name": "Steve"
}]
}
'
echo
curl -XPOST localhost:9200/test/car/1/_update -d '{
"script" : "ctx._source.creators += new_creator",
"params" : {
"new_creator" : {"name": "John"}
}
}'
echo
curl "localhost:9200/test/car/1?pretty=true"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment