public

elasticsearch - Delete By Query API - data option does not delete data

  • Download Gist
elasticsearch_delete_by_query_api
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
elasticsearch 0.19.0
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.2)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
 
 
 
//shows 32 documents
curl -XGET 'http://localhost:9200/contacts/linkedin/_search?pretty=true' -d '{
query:
{ bool:
{ should: [ { matchAll: {} } ],
must: [ { text: { user: { query: "stephanfortelny@gmail.com", operator: "and" } } } ] } }
}'
 
//does not work yet
curl -XDELETE 'http://localhost:9200/contacts/linkedin/_query' -d '{
"term" : { "user" : "stephanfortelny@gmail.com" }
}'
{"ok":true,"_indices":{"contacts":{"_shards":{"total":5,"successful":5,"failed":0}}}}
 
//stills shows same 32 documents
curl -XGET 'http://localhost:9200/contacts/linkedin/_search?pretty=true' -d '{
query:
{ bool:
{ should: [ { matchAll: {} } ],
must: [ { text: { user: { query: "stephanfortelny@gmail.com", operator: "and" } } } ] } }
}'
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 32,
"max_score" : 1.288314,
"hits" : [ {
"_index" : "contacts",
"_type" : "linkedin",
"_id" : "RonYEGYKRlS4yUgSNx8INw"
...
}
 
//works
curl -XDELETE 'http://localhost:9200/contacts/linkedin/_query?q=user:stephanfortelny@gmail.com'
{"ok":true,"_indices":{"contacts":{"_shards":{"total":5,"successful":5,"failed":0}}}}
 
//documents get deleted
curl -XGET 'http://localhost:9200/contacts/linkedin/_search?pretty=true' -d '{
query:
{ bool:
{ should: [ { matchAll: {} } ],
must: [ { text: { user: { query: "stephanfortelny@gmail.com", operator: "and" } } } ] } }
}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.