# Unable to delete by query

**URL:** <https://discuss.elastic.co/t/unable-to-delete-by-query/164198>\
**Category:** Elasticsearch\
**Created:** [January 14, 2019, 9:02pm UTC](https://discuss.elastic.co/t/unable-to-delete-by-query/164198 "2019-01-14T21:02:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdndude](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sdndude/32/24608_2.png) [@sdndude](https://discuss.elastic.co/u/sdndude)\
**Post date:** [January 14, 2019, 9:02pm UTC](https://discuss.elastic.co/t/unable-to-delete-by-query/164198/1 "2019-01-14T21:02:26Z")

</div>

I do some post processing on some logs for another system that we use and I am trying to get rid of docs that have invalid/missing data in them. This is not the best way to solve this, but for now it's what I have to do. I have a list of all of the doc ids that need to be deleted, but I cannot get them to delete with an error about final mappings. Did a search on the final mapping error and while I understand it, I really don't care about it and just want the docs gone.

I have a file called notfound.txt that contains all of the ids and I was trying to loop through it and send delete\_by\_query but I get the following error:

```auto
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [threat-2018.12] as the final mapping would have more than 1 type: [delete_by_query, doc]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [threat-2018.12] as the final mapping would have more than 1 type: [delete_by_query, doc]"},"status":400}

```

Here is the cmd line I am running to do the delete:

```auto
 for line in `sort -u notfound.txt`;do curl -XPOST -H'Content-Type: application/json' 'http://elasticsearch:9200/threat-2018.12/delete_by_query' -d '{
  "query": {
    "match": {
      "_id": "$line"
    }
  }
}'; done

```

Any help is greatly appreciated.

---

<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 11, 2019, 9:02pm UTC](https://discuss.elastic.co/t/unable-to-delete-by-query/164198/2 "2019-02-11T21:02:32Z")

</div>

Closed on February 11, 2019, 9:02pm UTC

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