Delete documents based on search criteria from elasticsearch index

Hi All,

We store below kind of data in elasticsearch index namely, mydevices. The index contains information for every few seconds related to the devices whether its up or not, which is like, if the document having status as 0 then its device is down, else device is up.

The index stores both the data, i.e., device down, as well as device up. I am interested to remove documents if status is 0.

Can someone please help with any query for deleting the documents from the index if the status value is 0.

here is the sample data for your reference -

Location: 'L1' Device Id: '9hBEyixlnmzCbv5sVev6Iv', Device Name: 'VELP0438H' --> Status: 0
Location: 'L2' Device Id: 'ZpZ9AP52EEL12h71YoUtZB', Device Name: 'VELP1208H' --> Status: 0
Location: 'L3' Device Id: 'ZpZ9AP52EEL81h71YoUtZB', Device Name: 'VELP1181H' --> Status: 1
Location: 'L1' Device Id: '9hBEyixlnmzCbv5sVev6Iv', Device Name: 'VELP0438H' --> Status: 0
Location: 'L2' Device Id: 'ZpZ9AP52EEL12h71YoUtZB', Device Name: 'VELP1208H' --> Status: 1
Location: 'L3' Device Id: 'ZpZ9AP52EEL81h71YoUtZB', Device Name: 'VELP1181H' --> Status: 0
Location: 'L1' Device Id: '9hBEyixlnmzCbv5sVev6Iv', Device Name: 'VELP0438H' --> Status: 0
Location: 'L2' Device Id: 'ZpZ9AP52EEL12h71YoUtZB', Device Name: 'VELP1208H' --> Status: 0
Location: 'L3' Device Id: 'ZpZ9AP52EEL81h71YoUtZB', Device Name: 'VELP1181H' --> Status: 11

You may need Delete By Query API. Because the deleted documents can not be recoverable in Elasticsearch, please verify your DSL can work well before applying it in production env .

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