我正在尝试实现Elasticsearch API。我在系统接受nodeBuilder时遇到错误。这是代码 -
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.Client;
//import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.*;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.node.NodeBuilder.*;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
// on startup
Node node = nodeBuilder().node(); // nodeBuilder not recognised.
Client client = node.client();
// on shutdown
node.close();
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.2.0</version>
</dependency>
客户得到认可。有什么想法吗?
答案 0 :(得分:1)
ClientBuilder
。
您可以使用org.elasticsearch.common.settings.Settings.builder()
,它会为您提供Builder
的实例。
Exp:
Settings.Builder elasticsearchSettings =
Settings.builder()
.put("http.enabled", "true")
.put("index.number_of_shards", "1")
.put("path.data", new File(tmpDir, "data").getAbsolutePath())
.put("path.logs", new File(tmpDir, "logs").getAbsolutePath())
.put("path.work", new File(tmpDir, "work").getAbsolutePath())
.put("path.home", tmpDir);
答案 1 :(得分:1)
NodeBuilder已被删除。虽然直接在应用程序中使用Node不受官方支持,但它仍然可以使用Node(Settings)构造函数构建。 请参阅 - https://www.elastic.co/guide/en/elasticsearch/reference/5.5/breaking_50_java_api_changes.html
答案 2 :(得分:-1)
org.elasticsearch.node.Node node = org.elasticsearch.node.NodeBuilder.nodeBuilder().node();
我还有一些使用节点的依赖项,因此系统无法解析弹性搜索。资格证明了它。