[英]Elasticsearch local node client NPE when creating index in java test
I am using elasticsearch (v2.3.2/Windows 7) local node to create an index in a java test which is throwing an null pointer exception. 我正在使用elasticsearch(v2.3.2 / Windows 7)本地节点在抛出空指针异常的Java测试中创建索引。
The test code is as follows: 测试代码如下:
CreateIndexResponse response = esClient.admin().indices().prepareCreate("mytestindex")
.setSettings(Settings.builder()
.put("number_of_replicas", 0)
.put("number_of_shards", 1))
.execute().actionGet();
I have verified esClient is created by spring and is not null. 我已验证esClient由spring创建,并且不为null。 The code to create the client is:
创建客户端的代码是:
@Bean
public Client localElasticsearchClient() {
Settings settings = Settings.settingsBuilder()
.put("path.home", "/tmp/elasticsearch")
.put("path.data", "/tmp/elasticsearch")
.build();
return NodeBuilder.nodeBuilder()
.local(true)
.settings(settings)
.build()
.client();
}
The stacktrace is as follows: stacktrace如下:
java.lang.NullPointerException
at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.<init>(TransportMasterNodeAction.java:129)
at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:107)
at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:51)
at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:137)
at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:85)
at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:58)
I saw something here about it but there was no info on how to correct it. 我在这里看到了一些东西,但是没有有关如何更正它的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.