DELETE documents documents that have field date1 in the given interval and the value of "date1 - date2" is greater than 1 hour

We have a basic index with two fields: date1 and date2.

PUT your_index
{
  "mappings": {
    "your_type": {
      "properties": {
        "time1": {
          "type":   "date",
        },
        "time2": {
          "type":   "date",
        }
      }
    }
  }
}

I want to make queries that DELETE documents that have field date1 in the given interval and the value of "date1 - date2" is greater than 1 hour.

Classically, I can make a range in the date1 field to add the appropriate date range.

{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "date1": {
              "gte": "2019-11-01 ",
              "lte": "2019-11-30"
            }
          }
        }
      ]
    }
  }
}

But how to add a second condition (logical AND between conditions)?

So how to add to the query "value of "date1 - date2" is greater than 1 hour."?

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