# Unable to delete the documents when the index is full

**URL:** <https://discuss.elastic.co/t/unable-to-delete-the-documents-when-the-index-is-full/260201>\
**Category:** Elasticsearch\
**Created:** [January 5, 2021, 12:15pm UTC](https://discuss.elastic.co/t/unable-to-delete-the-documents-when-the-index-is-full/260201 "2021-01-05T12:15:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![subash](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subash/32/59912_2.png) [@subash](https://discuss.elastic.co/u/subash)\
**Post date:** [January 5, 2021, 12:15pm UTC](https://discuss.elastic.co/t/unable-to-delete-the-documents-when-the-index-is-full/260201/1 "2021-01-05T12:15:11Z")

</div>

I am unable to delete the documents from an index having the maximum number of documents (2147483519).

getting the below exception. Please help me to get this resolved.

```
"cause" : {
        "type" : "illegal_argument_exception",
        "reason" : "number of documents in the index cannot exceed 2147483519"
      }

```

below is the query

```
POST logs-68-2425/_delete_by_query
{
  "query": {
    "range": {
      "@timestamp": {
        "lt": 1602374400000,
        "format": "epoch_millis"
      }
    }
  }
}
```

---

<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:** [January 5, 2021, 3:17pm UTC](https://discuss.elastic.co/t/unable-to-delete-the-documents-when-the-index-is-full/260201/2 "2021-01-05T15:17:13Z")

</div>

You need to reindex the data instead IMO.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 5, 2021, 3:27pm UTC](https://discuss.elastic.co/t/unable-to-delete-the-documents-when-the-index-is-full/260201/3 "2021-01-05T15:27:52Z")

</div>

Have you tried using the split index API (assuming you are on a recent version)? Not sure if it would work on a completely full shard but it could be worth exploring...

---

<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:** [January 5, 2021, 3:49pm UTC](https://discuss.elastic.co/t/unable-to-delete-the-documents-when-the-index-is-full/260201/4 "2021-01-05T15:49:15Z")

</div>

That was my initial answer to be honest but the error message makes me think that the limit is per index and not per shard? Unless this is an error message coming directly from Lucene?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 5, 2021, 3:56pm UTC](https://discuss.elastic.co/t/unable-to-delete-the-documents-when-the-index-is-full/260201/5 "2021-01-05T15:56:22Z")

</div>

I assumed it was a single shard index given that the default now is 1 primary shard per index.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 5, 2021, 4:13pm UTC](https://discuss.elastic.co/t/unable-to-delete-the-documents-when-the-index-is-full/260201/6 "2021-01-05T16:13:13Z")

</div>

As you can see from the discussion @subash it would be useful to know which version of Elasticsearch you are using as well as get some index and/or shard statistics.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [January 5, 2021, 4:21pm UTC](https://discuss.elastic.co/t/unable-to-delete-the-documents-when-the-index-is-full/260201/7 "2021-01-05T16:21:43Z")

</div>

> [@dadoonet](#):
>
> Unless this is an error message coming directly from Lucene

Yeah it's from Lucene so "index" means "shard" in Elasticsearch terminology.

The fundamental issue is that deleting a document requires indexing another document to record the delete, and that happens before the deleted document goes away. I _suspect_ that splitting the index would work, but if that doesn't work then reindexing would work too.

---

<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:** [February 2, 2021, 4:21pm UTC](https://discuss.elastic.co/t/unable-to-delete-the-documents-when-the-index-is-full/260201/8 "2021-02-02T16:21:51Z")

</div>

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