Delete by Query - Based on time

Hello,

I am trying to delete data from Elastic Search based on timestamp. I could not find a way to do it after giving multiple tries with the below:

POST index_name/_delete_by_query
{
"query": {
"range" : {
"@timestamp" : {
"gte" : "01/01/2016",
"lte" : "05/01/2017",
"format": "dd/MM/yyyy||yyyy"
}
}
}
}

Just want to understand what am I missing here? :thinking::thinking:

Hi Ganesh,

The query seems to be correct. What is the response that you are getting?
Also, can you try the below query

GET index_name/_search
{
"query": {
"range" : {
"@timestamp" : {
"gte" : "01/01/2016",
"lte" : "05/01/2017",
"format": "dd/MM/yyyy||yyyy"
}
}
}
}

and see if you can retrieve any results?

Hi Krishna,

I get the below response

image

Hi Ganesh,

The output that you got explains it. There is no data in the given range of timestamp. hits -> total = 0. As there is no data in the given timestamp range you were not able to delete.

Hi Krishna,

Yes, I understood that too. But was wondering why does this query not show me data when I actually have some data that I see on my graph for dates ranging between 1st Jan to 21st Jan.

Now, I am quite embarrassed to say this :laughing::laughing::roll_eyes::roll_eyes: But the problem is with the query that I wrote which refers to year 2017, where as we are in 2018.

But your inputs helped me figure that out :slight_smile:. Thanks a lot for your support.

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