# Trying to delete documents in index older than XXX

**URL:** <https://discuss.elastic.co/t/trying-to-delete-documents-in-index-older-than-xxx/339852>\
**Category:** Elasticsearch\
**Created:** [August 1, 2023, 7:45pm UTC](https://discuss.elastic.co/t/trying-to-delete-documents-in-index-older-than-xxx/339852 "2023-08-01T19:45:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![guy\_guy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guy_guy/32/124202_2.png) [@guy\_guy](https://discuss.elastic.co/u/guy_guy)\
**Post date:** [August 1, 2023, 7:45pm UTC](https://discuss.elastic.co/t/trying-to-delete-documents-in-index-older-than-xxx/339852/1 "2023-08-01T19:45:00Z")

</div>

I need to delete some documents from indexes older than XXX days, but delete\_by\_query doesn't seem to be working for me.

Here is an example query I'm trying to run

```auto
POST shipment-log/_delete_by_query
{
  "query": {
    "range": {
      "@timestamp": {
        "lte": "2023"
      }
    }
  }
}

```

and here is the response I get

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "action_request_validation_exception",
        "reason" : "Validation Failed: 1: query is missing;"
      }
    ],
    "type" : "action_request_validation_exception",
    "reason" : "Validation Failed: 1: query is missing;"
  },
  "status" : 400
}

```

conversely I can run this same command on a different index

```auto
POST hrapp-log/_delete_by_query
{
  "query": {
    "range": {
      "@timestamp": {
        "lte": "2023"
      }
    }
  }
}

```

and I do not get an error response but rather it just doesn't work

```auto
{
  "took" : 50,
  "timed_out" : false,
  "total" : 0,
  "deleted" : 0,
  "batches" : 0,
  "version_conflicts" : 0,
  "noops" : 0,
  "retries" : {
    "bulk" : 0,
    "search" : 0
  },
  "throttled_millis" : 0,
  "requests_per_second" : -1.0,
  "throttled_until_millis" : 0,
  "failures" : []
}

```

it may be the @lte condition but I do not understand why I'm getting an error for one index but not for another

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 29, 2023, 7:45pm UTC](https://discuss.elastic.co/t/trying-to-delete-documents-in-index-older-than-xxx/339852/2 "2023-08-29T19:45:47Z")

</div>

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