Created
May 14, 2012 13:10
-
-
Save Avatah/2693858 to your computer and use it in GitHub Desktop.
ElasticSearch parent child mapping & ttl on parent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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