# Why is my \_delete\_by\_query being ignored?

**URL:** <https://discuss.elastic.co/t/why-is-my-delete-by-query-being-ignored/124409>\
**Category:** Elasticsearch\
**Created:** [March 17, 2018, 5:41pm UTC](https://discuss.elastic.co/t/why-is-my-delete-by-query-being-ignored/124409 "2018-03-17T17:41:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordanglassman](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@jordanglassman](https://discuss.elastic.co/u/jordanglassman)\
**Post date:** [March 17, 2018, 5:41pm UTC](https://discuss.elastic.co/t/why-is-my-delete-by-query-being-ignored/124409/1 "2018-03-17T17:41:25Z")

</div>

I understand that \_delete\_by\_query is now added to core, and no longer requires a plugin.

Using org.elasticsearch:elasticsearch:5.5.2, I am starting a org.elasticsearch.node.Node with:

```
public void before() throws Exception {
    Settings settings = Settings.builder()
            .put(NetworkModule.HTTP_TYPE_KEY, Netty4Plugin.NETTY_HTTP_TRANSPORT_NAME)
            .put(NetworkModule.TRANSPORT_TYPE_KEY, Netty4Plugin.NETTY_TRANSPORT_NAME)
            .put(NetworkModule.HTTP_ENABLED.getKey(), true)
            .put(HttpTransportSettings.SETTING_HTTP_PORT.getKey(), port)
            .put("path.home", path.getAbsolutePath())
            .build();
    node = new MyNode(InternalSettingsPreparer.prepareEnvironment(settings, null), Collections.singleton(Netty4Plugin.class)).start();
}

```

Then, I create a trivial index, add a document, query for the document, and then try to delete. ES keeps treating "\_delete\_by\_query" like an id or a type mapping, not an API endpoint. What am I doing wrong?

When running the same version of ES as an application (ie. not from Java code), the endpoint works as expected.

```
$ curl -XPUT 'localhost:59200/foo?pretty' -H 'Content-Type: application/json' -d'
> {
> "mappings": {
> "bar": {
> "properties": {
> "baz": {
> "type": "keyword"
> }
> }
> }
> }
> }
> '
{
  "acknowledged" : true,
  "shards_acknowledged" : true
}

$ curl -XPUT 'localhost:59200/foo/bar/1?pretty' -H 'Content-Type: application/json' -d'{"baz":"lol"}'
{
  "_index" : "foo",
  "_type" : "bar",
  "_id" : "1",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "created" : true
}

$ curl 'localhost:59200/foo/bar/_search?pretty'
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "foo",
        "_type" : "bar",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "baz" : "lol"
        }
      }
    ]
  }
}

$ curl 'localhost:59200/foo/bar/_search?pretty' -d'
> {
> "query": {
> "match": {
> "baz": "lol"
> }
> }
> }
> '
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.2876821,
    "hits" : [
      {
        "_index" : "foo",
        "_type" : "bar",
        "_id" : "1",
        "_score" : 0.2876821,
        "_source" : {
          "baz" : "lol"
        }
      }
    ]
  }
}

$ curl -XPOST 'localhost:59200/foo/bar/_delete_by_query?pretty' -d'
> {
> "query": {
> "match": {
> "baz": "lol"
> }
> }
> }
> '
{
  "_index" : "foo",
  "_type" : "bar",
  "_id" : "_delete_by_query",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "created" : true
}

$ curl -XPOST 'localhost:59200/foo/_delete_by_query?pretty' -d'
> {
> "query": {
> "match": {
> "baz": "lol"
> }
> }
> }
> '
{
  "error" : {
    "root_cause" : [
      {
        "type" : "invalid_type_name_exception",
        "reason" : "Document mapping type name can't start with '_', found: [_delete_by_query]"
      }
    ],
    "type" : "invalid_type_name_exception",
    "reason" : "Document mapping type name can't start with '_', found: [_delete_by_query]"
  },
  "status" : 400
}
```

---

<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:** [March 18, 2018, 10:58am UTC](https://discuss.elastic.co/t/why-is-my-delete-by-query-being-ignored/124409/2 "2018-03-18T10:58:41Z")

</div>

Starting a node in Java is not supported.  
So you are missing some modules here IMO.

---

<div class="post-metadata">

**Author:** ![jordanglassman](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@jordanglassman](https://discuss.elastic.co/u/jordanglassman)\
**Post date:** [March 18, 2018, 2:16pm UTC](https://discuss.elastic.co/t/why-is-my-delete-by-query-being-ignored/124409/3 "2018-03-18T14:16:06Z")

</div>

Well, this is just for testing. 😃

Which modules are missing and is it possible to add them?

Alternatively, is there another way to fire up an in-memory ES instance for unit/integration testing?

---

<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:** [March 18, 2018, 3:50pm UTC](https://discuss.elastic.co/t/why-is-my-delete-by-query-being-ignored/124409/4 "2018-03-18T15:50:29Z")

</div>

> Which modules are missing?

> <https://github.com/elastic/elasticsearch/tree/main/modules/reindex>
>
> //github.com/elastic/elasticsearch/tree/main/modules/reindex

> and is it possible to add them?

No. I don't think it's possible. AFAIK they are not published as separate artifacts and are bundled in the final distribution.

> [@jordanglassman](#):
>
> Alternatively, is there another way to fire up an in-memory ES instance for unit/integration testing?

I wrote some ideas in [In memory testing with RestHighLevelClient - #6 by dadoonet](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196/6).

---

<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:** [April 15, 2018, 3:51pm UTC](https://discuss.elastic.co/t/why-is-my-delete-by-query-being-ignored/124409/5 "2018-04-15T15:51:02Z")

</div>

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