# Does \_delete\_by\_query need a plugin or not? ES version 5.5

**URL:** <https://discuss.elastic.co/t/does-delete-by-query-need-a-plugin-or-not-es-version-5-5/246343>\
**Category:** Elasticsearch\
**Created:** [August 25, 2020, 6:31pm UTC](https://discuss.elastic.co/t/does-delete-by-query-need-a-plugin-or-not-es-version-5-5/246343 "2020-08-25T18:31:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![makons](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/makons/32/74314_2.png) [@makons](https://discuss.elastic.co/u/makons)\
**Post date:** [August 25, 2020, 6:31pm UTC](https://discuss.elastic.co/t/does-delete-by-query-need-a-plugin-or-not-es-version-5-5/246343/1 "2020-08-25T18:31:05Z")

</div>

So I've seen [this post](https://www.elastic.co/blog/core-delete-by-query-is-a-plugin) from way before in 2015 saying that delete by query is supported through a plugin `delete-by-query`. This was for the Elasticsearch version 2.0.0. However, there's a [newer post](https://www.elastic.co/guide/en/elasticsearch/plugins/master/plugins-delete-by-query.html#plugins-delete-by-query) which says that now this function is inside the core API, and no plugin is needed. If I got it correctly, newer update is valid from version 5.0 onwards.

Now, my problem is that Elasticsearch does not recognise `_delete_by_query` function, and inserts a document with that function name as its ID - `_id: "_delete_by_query"`. This happens if I run:

```auto
POST <index_name>/<mapping_name>/_delete_by_query
{
    "query": { ... }
}

```

If I try to call it without the specified mapping:

```auto
POST <index_name>/_delete_by_query
{
    "query": { ... }
}

```

I get an error:

```auto
{
    "type": "invalid_type_name_exception",
    "reason": "Document mapping type name can't start with '_', found: [_delete_by_query]"
}

```

[This post](https://discuss.elastic.co/t/delete-by-query-error-invalid-type-name-exception/119629) mentions that the error happens if the plugin is needed, and ES cannot recognise the `_delete_by_query` function. I'm running Elasticsearch 5.5.2, so how could that be possible? If this is not the case, what causes then this behaviour?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 26, 2020, 4:24am UTC](https://discuss.elastic.co/t/does-delete-by-query-need-a-plugin-or-not-es-version-5-5/246343/2 "2020-08-26T04:24:19Z")

</div>

FYi 5.X has been [EOL](https://www.elastic.co/support/eol) for quite some time, you should really upgrade as a matter of urgency.

[The docs](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-delete-by-query.html) show this as an example, with no type defined;

```auto
POST twitter/_delete_by_query
{
  "query": { 
    "match": {
      "message": "some message"
    }
  }
}

```

If that's not working, what does your query look like?

---

<div class="post-metadata">

**Author:** ![makons](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/makons/32/74314_2.png) [@makons](https://discuss.elastic.co/u/makons)\
**Post date:** [August 26, 2020, 12:22pm UTC](https://discuss.elastic.co/t/does-delete-by-query-need-a-plugin-or-not-es-version-5-5/246343/3 "2020-08-26T12:22:17Z")

</div>

Thanks for the reply, as well as version change suggestion, I'll look into that!

So, my query is like this:

```auto
POST <index_name>/_delete_by_query?routing=<parent_type>
{
  "query" : {
    "bool" : {
      "must_not" : [
        {
          "has_parent" : {
            "query" : {
              "match_all" : {
                "boost" : 1.0
              }
            },
            "parent_type" : <parent_type>,
            "score" : false,
            "ignore_unmapped" : false,
            "boost" : 1.0
          }
        }
      ],
      "disable_coord" : false,
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  }
}

```

I've tried both that and `POST <index_name>/<child_type>/_delete_by_query?routing=<parent_type>` with the same query. When child type is specified, the record is inserted in the ES with `_id="_delete_by_query"`, but when I leave it out I get that `invalid_type_name_exception`.

However, I did decent amount of digging and found [this topic](https://discuss.elastic.co/t/delete-by-query-api-invalid-type-name-exception/169420) that seems to be related to my issue. I indeed run an embedded instance for testing purposes, and `_delete_by_query` is not supported there. The workaround mentioned was to include reindex plugin in the elasticsearch configuration. I haven't been able to make that workaround work, but in the end, as the last comment on that thread says, it's not a reliable solution.

In the end, I'll most likely drop this unit test that I had trouble with, and only rely on the integration test that uses a standalone elasticsearch server, which does support `_delete_by_query`.

---

<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:** [September 23, 2020, 12:22pm UTC](https://discuss.elastic.co/t/does-delete-by-query-need-a-plugin-or-not-es-version-5-5/246343/4 "2020-09-23T12:22:32Z")

</div>

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