# Delete\_by\_query number of documents Error

**URL:** <https://discuss.elastic.co/t/delete-by-query-number-of-documents-error/257737>\
**Category:** Elasticsearch\
**Created:** [December 5, 2020, 2:46pm UTC](https://discuss.elastic.co/t/delete-by-query-number-of-documents-error/257737 "2020-12-05T14:46:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lstoneir](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lstoneir](https://discuss.elastic.co/u/lstoneir)\
**Post date:** [December 5, 2020, 2:46pm UTC](https://discuss.elastic.co/t/delete-by-query-number-of-documents-error/257737/1 "2020-12-05T14:46:17Z")

</div>

Hi, I run this code:

```auto
POST topf/_delete_by_query?conflicts=proceed&max_docs=500000
{
  "query": {
    "range": {
      "time": {
        "gte": "2020-09-18T03:00:00",
        "lte": "2020-09-18T04:00:00"
      }
    }
  }
}

```

I get this response:

```auto
{
  "took": 197,
  "timed_out": false,
  "total": 500000,
  "deleted": 0,
  "batches": 1,
  "version_conflicts": 0,
  "noops": 0,
  "retries": {
    "bulk": 0,
    "search": 0
  },
  "throttled_millis": 0,
  "requests_per_second": -1,
  "throttled_until_millis": 0,
  "failures": [
    {
      "index": "topf",
      "type": "_doc",
      "id": "5P9Jn3QB8h4zPTyXs00T",
      "cause": {
        "type": "illegal_argument_exception",
        "reason": "number of documents in the index cannot exceed 2147483519"
      },
      "status": 400
    },
.
.
.
]
}

```

my index setting:  
docs num 2097483519  
primary shard: 1  
replica shard: 0

How can i save my index and delete old docs?  
i dont want delete whole of my index.  
any solutions?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 5, 2020, 6:29pm UTC](https://discuss.elastic.co/t/delete-by-query-number-of-documents-error/257737/2 "2020-12-05T18:29:57Z")

</div>

You should reindex in new indices using the reindex API and then drop the old index

---

<div class="post-metadata">

**Author:** ![lstoneir](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lstoneir](https://discuss.elastic.co/u/lstoneir)\
**Post date:** [December 6, 2020, 7:36am UTC](https://discuss.elastic.co/t/delete-by-query-number-of-documents-error/257737/3 "2020-12-06T07:36:51Z")

</div>

Hi @dadoonet,  
Are you sure? Is there any other solutions?  
I have 80GB free space, and index volume is 255GB. So i must buy new HDD and increase my HDD free space ☹

---

<div class="post-metadata">

**Author:** ![kelk](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kelk](https://discuss.elastic.co/u/kelk)\
**Post date:** [December 6, 2020, 8:31am UTC](https://discuss.elastic.co/t/delete-by-query-number-of-documents-error/257737/4 "2020-12-06T08:31:59Z")

</div>

I feel you have allowed the single index to grow huge and can't do much operations in that. (May be ILM or curator to rollover when you create it, so it rolls over correctly), so it is not held as a single index but more like topf\_2020-12-01.00000 etc.  
I can't see any other options other than dadoonet mentioned

---

<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:** [January 3, 2021, 8:32am UTC](https://discuss.elastic.co/t/delete-by-query-number-of-documents-error/257737/5 "2021-01-03T08:32:08Z")

</div>

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