How-to delete objects in index by query?


(Yuriy Vasilyev) #1

Hi to all!

When I'm sending request for delete objects by query, ElasticSearch
removes all records in index, not only one with id 1404.0.0 (I have
string id)
My request here

DELETE http://10.54.xx.xx:9200/test_create/address_search/?pretty=true
HTTP/1.1
Accept: application/json
Content-Type: application/json
Host: 10.54.18.47:9200
Content-Length: 64
Expect: 100-continue
Connection: Keep-Alive

{ "query" : {
"terms" : { "id" : ["1404.0.0"] }
} }

Thanks,
Yuriy


(David Stendardi) #2

I think you are using the wrong endpoint : You are deleting the whole
type "address_search"

You should replace :
http://10.54.xx.xx:9200/test_create/address_search/?pretty=true
by : http://10.54.xx.xx:9200/test_create/address_search/_query?pretty=true

as stated here :
http://www.elasticsearch.org/guide/reference/api/delete-by-query.html

2012/2/17 Yuriy Vasilyev rus.xprogrammer@gmail.com:

Hi to all!

When I'm sending request for delete objects by query, ElasticSearch
removes all records in index, not only one with id 1404.0.0 (I have
string id)
My request here

DELETE http://10.54.xx.xx:9200/test_create/address_search/?pretty=true
HTTP/1.1
Accept: application/json
Content-Type: application/json
Host: 10.54.18.47:9200
Content-Length: 64
Expect: 100-continue
Connection: Keep-Alive

{ "query" : {
"terms" : { "id" : ["1404.0.0"] }
} }

Thanks,
Yuriy

--
David Stendardi


(Yuriy Vasilyev) #3

I added _query and fixed my query as

{
"terms" : { "id" : ["1404.0.0"] }
}

All works fine!

Thank you!


(system) #4