How to write a range query for a date field with an interval on Elasticsearch?

This is my current query which fetches documents which are older than 365 days from now.

"query": {
 "bool": {
  "must": [
    {
      "match": {
        "doc_type": "AP - ACH CHECKS"
      }
    },
    {
      "range": {
        "capture_date": {
          "lte": "now-365d"
        }
      }
    }
  ]
}

}

But I need to fetch the documents which are older than 365 days from the capture_date field. So tried like below and didn't work

{
  "range": {
    "capture_date": {
      "lte": "capture_date-365d"
    }
  }
}

What should be the correct format?

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