Delete by query in elasticsearch

Hi,
I'm using below code to delete my index data using curator. In my version 2.1 elasticsearch working fine but new version its showing some error. Please correct my curl file

curl -XDELETE 'http://localhost:9200/logstash-dd.zephyr_log/_delete_by_query ' -d "
{
  "query": 
  {
    "range": 
                {
      "zephyr_timestamp": 
                  { 				  		
				  "gte": \"$from_dataset_date\",
				  "lte": \"$to_dataset_date\"
				  
      }
    }
  }
}"

The delete by query API has changed since 2.1 and therefore the syntax is a bit different to before. Please see here for details on the new API: https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-delete-by-query.html

Thank for your update.

I have one issue, when i try to install delete by query in my linux machine i'm getting following error,

[root@ bin]# cd /usr/share/elasticsearch
[root@ elasticsearch]# sudo bin/elasticsearch-plugin install file:////root/elk/elk_software/delete-by-query-2.2.1.zip
-> Downloading file:////root/elk/elk_software/delete-by-query-2.2.1.zip
[=================================================] 100%  
ERROR: `elasticsearch` directory is missing in the plugin zip

Make sure that the version of the delete-by-query plugin you are installing matches the exact version of the elasticsearch server. An easier way to make sure the correct plugin version is installed is to run bin/elasticsearch-plugin install delete-by-query

when i try to install with latest version of delete by query version 2.4.5 even-though i getting same error.

What version of Elasticsearch are you running?

Elasticsearch version 5.2.1

In which case you need to use the 5.2.1 version of delete_by_query which is automatically installed with Elasticsearch 5.2.1 so you don't need to separately install a plugin

we installed elasticsearch from RPM file and we didn't find any delete by query plugin in plugin folder so that try to install in it

plugins that are included by default are stored in modules folder.

But in that folder also i could find that plugin name by default if i'm wrong correct me,

The 5.2.1 version of delete_by_query is included as part of the reindex module. Try using the 5.2.1 Delete By Query API as described in https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-delete-by-query.html. It should work

HI,
I'm try to delete few days events from my index and i'm getting error also, please take a look up for my query if any error in code please correct me

curl -XPOST 'http://localhost:9200/logstash-dd.zephyr_log/_delete_by_query ' -d "
{
  \"query\": 
  {
    \"range\": 
                {
      \"zephyr_timestamp\": 
                  { 				  		
				 \"gte\": "2017-06-01 00:00:00,000",
				  \"lte\": "2017-06-03 23:59:59,999"
				  
      }
    }
  }
}"

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