Created
December 9, 2011 20:28
-
-
Save Alex-Ikanow/1453163 to your computer and use it in GitHub Desktop.
Various "nested" problems with elasticsearch 0.17.9 and 0.18.5 part 2
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
Steps 1-3 are the same as part 1 (https://gist.github.com/1453137) | |
1] Create an index called "nested_test" (eg I did this from elasticsearch-head) with 5 shards and 0 replicas | |
(or presumably something like | |
curl -XPUT 'http://localhost:9200/nested_test/' -d ' | |
index : | |
number_of_shards : 5 | |
number_of_replicas : 0 | |
' | |
would be equivalent) | |
2] Create a type mapping | |
curl -XPUT 'http://localhost:9200/nested_test/nested/_mapping' -d '{"type1":{"properties":{"obj1":{"type":"nested"}}}}' | |
3] Add a test object (I'll fix the ID here for [4]'s sake) | |
curl -XPOST 'http://localhost:9200/nested_test/nested/Qo3xXbFMTOG273p2048sMw' -d '{"obj1":[{"name":"blue",count:4},{"name":"green",count:6}]}' | |
4] Deleting by _id works fine, eg | |
curl -XDELETE 'http://localhost:9200/nested_test/nested/Qo3xXbFMTOG273p2048sMw' | |
(or whatever _id is returned from [3]) | |
Then check the index in elasticsearch head (sorry, too lazy to dig out the REST for status), and there are 0 docs | |
5] However deleting by query leaves orphaned nested children | |
curl -XPOST 'http://localhost:9200/nested_test/nested/' -d '{"obj1":[{"name":"blue",count:4},{"name":"green",count:6}]}' | |
(reinsert) | |
curl -XDELETE 'http://localhost:9200/nested_test/nested/_query' -d '{"match_all":{}}' | |
Checking the index shows 2 objects remaining, although querying "match_all" either using nested or normally (expectedly) returns 0 documents |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment