Skip to content

Instantly share code, notes, and snippets.

@Avatah
Created May 14, 2012 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Avatah/2693858 to your computer and use it in GitHub Desktop.
Save Avatah/2693858 to your computer and use it in GitHub Desktop.
ElasticSearch parent child mapping & ttl on parent
curl -XPUT http://localhost:9200/test/parent/_mapping -d '{"parent" : {"_ttl": {"enabled": true}}}'
curl -XPUT http://localhost:9200/test/child/_mapping -d '{"child": {"_parent": {"type": "parent"}} }'
curl -XPUT http://localhost:9200/test/parent/parent1?ttl=60000 -d '{"name" : "parent1"}'
curl -XPUT http://localhost:9200/test/child/child1?parent=parent1 -d '{"name" : "child1"}'
curl -XPUT http://localhost:9200/test/child/child2?parent=parent1 -d '{"name" : "child2"}'
After a few minutes parent1 is deleted but children are not.
Also:
curl -XGET http://localhost:9200/test/child/child1?fields=_parent
{"_index":"test","_type":"child","_id":"child1","_version":1,"exists":true,"fields":{"_parent":"parent1"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment