Curl Xdelete with ELASTICSEARCH 6.1


(pitt) #1

Hello

Do you know how I can delete document in one curl command ?
I have a index called "myindex". I want to delete all document where the field prediction is like "yes"

With Elasticsearch 2.1, I use:

curl.exe -XDELETE http://XX.XX.XX.XX:9200/myindex/core2/_query?q=prediction:yes

With Elasticsearch 6.1.1, it does not work.

Thanks.


(Christian Dahlqvist) #2

You can use the delete-by-query API.


(Val Crettaz) #3

The syntax you have was for ES 2.4. With ES 5 the delete by query API endpoint has changed name, from _query to _delete_by_query, so this should work (also make sure to use the POST method and not DELETE):

curl.exe -XPOST http://XX.XX.XX.XX:9200/myindex/core2/_delete_by_query?q=prediction:yes


(pitt) #4

Thanks!

It's ok with this syntax:

E:\curl.exe -XPOST http://xx.xx.xx.xx:9200/myindex/_delete_by_query?q=Prediction:yes 2>$NULL


(Val Crettaz) #5

Great, glad to hear it worked out!


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.