# DeleteByQuery Illegal state exception

**URL:** <https://discuss.elastic.co/t/deletebyquery-illegal-state-exception/84118>\
**Category:** Elasticsearch\
**Created:** [April 30, 2017, 7:40pm UTC](https://discuss.elastic.co/t/deletebyquery-illegal-state-exception/84118 "2017-04-30T19:40:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shira\_Bendor](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Shira\_Bendor](https://discuss.elastic.co/u/Shira_Bendor)\
**Post date:** [April 30, 2017, 7:40pm UTC](https://discuss.elastic.co/t/deletebyquery-illegal-state-exception/84118/1 "2017-04-30T19:40:54Z")

</div>

Hi,  
I'm testing this API and have this code:

```
        BulkByScrollResponse response =
            DeleteByQueryAction.INSTANCE.newRequestBuilder(m_client)
                    .filter(eventCondition.getQueryBuilder())
                    .get();

```

Which I copied from the documentation.

I got the following exception:

```
java.lang.IllegalStateException: failed to find action [org.elasticsearch.index.reindex.DeleteByQueryAction@5794e1cf] to execute
at org.elasticsearch.client.node.NodeClient.transportAction(NodeClient.java:116)
at org.elasticsearch.client.node.NodeClient.executeLocally(NodeClient.java:83)
at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:72)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:404)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:62)

```

Can someone please suggest why I'm seeing this?  
Thanks

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [May 1, 2017, 4:18pm UTC](https://discuss.elastic.co/t/deletebyquery-illegal-state-exception/84118/2 "2017-05-01T16:18:16Z")

</div>

Did you use the PreBuiltTransportClient like [this](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html)?

---

<div class="post-metadata">

**Author:** ![Shira\_Bendor](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Shira\_Bendor](https://discuss.elastic.co/u/Shira_Bendor)\
**Post date:** [May 3, 2017, 7:21pm UTC](https://discuss.elastic.co/t/deletebyquery-illegal-state-exception/84118/3 "2017-05-03T19:21:05Z")

</div>

You are correct.  
I did this test with an embedded node.  
Once I moved to the PreBuiltTransportClient it worked.  
I know embedded node is not supported but it's important to me to use it in this specific test.  
Can you explain why it isn't working? And if there is something else I could be doing to use this API with the embedded node?

Thanks

---

<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:** [May 31, 2017, 7:30pm UTC](https://discuss.elastic.co/t/deletebyquery-illegal-state-exception/84118/4 "2017-05-31T19:30:48Z")

</div>

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