我想知道是否有可能让 ES 1.3.1 插件运行客户端 API,以便我可以沿着我的 ElasticSearch 插件执行 ES 搜索?
我尝试了以下代码:
package org.elasticsearch.plugin.example;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.plugins.AbstractPlugin;
import java.util.Collection;
import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
public class ExamplePlugin extends AbstractPlugin {
@Override public String name() { return "example-plugin"; }
@Override public String description() { return "Example Plugin Description"; }
@Override public Collection<Class<? extends Module>> modules() {
//Trying to create a client to perform searching
Client client = NodeBuilder.nodeBuilder().client(true).node().client();
//returns error java.lang.AutoCloseable [not found];
Collection<Class<? extends Module>> modules = Lists.newArrayList();
modules.add(ExampleRestModule.class);
return modules;
}
}
但它返回以下编译错误:
[ERROR] class file for java.lang.AutoCloseable not found
关于如何使其工作的任何想法?
安装细节:
$ elasticsearch -v
Version: 1.3.1, Build: 2de6dc5/2014-07-28T14:45:15Z, JVM: 1.8.0_11
$ java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
来源:
包含文件的当前文件结构pom.xml
位于此处。