Reputation: 3632
I have run ES 2.3.3 in an embedded fashion but I'm unable to invoke the DeleteByQuery action due to the described exception. I added the DeleteByQuery plugin to my classpath and also set the plugin.types settings for my not but it is still not working.
My Maven dependencies:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>delete-by-query</artifactId>
<version>2.3.3</version>
</dependency>
My ES Setup:
Settings elasticsearchSettings = Settings.settingsBuilder()
.put("threadpool.index.queue_size", -1)
.put("path.home", options.getDirectory())
.put("plugin.types", DeleteByQueryPlugin.class.getName())
.build();
NodeBuilder builder = NodeBuilder.nodeBuilder();
node = builder.local(true).settings(elasticsearchSettings).node();
Invocation of the action which is used to truncate the index.
DeleteByQueryRequestBuilder builder = new DeleteByQueryRequestBuilder(node.client(), DeleteByQueryAction.INSTANCE);
builder.setIndices(indexName).setQuery(QueryBuilders.matchAllQuery()).execute().addListener(new ActionListener<DeleteByQueryResponse>() {
public void onResponse(DeleteByQueryResponse response) {
if (log.isDebugEnabled()) {
log.debug("Deleted index {" + indexName + "}. Duration " + (System.currentTimeMillis() - start) + "[ms]");
}
sub.onCompleted();
};
@Override
public void onFailure(Throwable e) {
log.error("Deleting index {" + indexName + "} failed. Duration " + (System.currentTimeMillis() - start) + "[ms]", e);
sub.onError(e);
}
});
Exception that I'm seeing:
Caused by: java.lang.IllegalStateException: failed to find action [org.elasticsearch.action.deletebyquery.DeleteByQueryAction@7c1ed3a2] to execute
at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:56) ~[elasticsearch-2.3.3.jar:2.3.3]
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359) ~[elasticsearch-2.3.3.jar:2.3.3]
Upvotes: 2
Views: 396
Reputation: 3632
I noticed that the Node builder invokes the node constructor with an empty plugin list. I extended the Node class in order to invoke this (protected) constructor.
public class ESNode extends Node {
protected ESNode(Settings settings, Collection<Class<? extends Plugin>> plugins) {
super(InternalSettingsPreparer.prepareEnvironment(settings, null), Version.CURRENT, plugins);
}
}
Using the ESNode all the needed plugin was loaded.
Set<Class<? extends Plugin>> classpathPlugins = new HashSet<>();
classpathPlugins.add(DeleteByQueryPlugin.class);
node = new ESNode(settings, classpathPlugins).start();
This may not be ideal but so far it is working just fine.
Upvotes: 3