弹性搜索和连接到QBOX错误 [英] Elasticsearch and connections to QBOX Error

查看:196
本文介绍了弹性搜索和连接到QBOX错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接qbox上的一个集群主机服务,我收到一条与路径有关的错误。我不确定如何指定端点API。有人有任何想法吗?

I am trying to connect to a cluster on qbox the hosting service and I get an error relating to path. I am unsure how to specify the endpoint API. Has anyone any ideas?

public   Map<String, Object> putJsonDocument(int partid, String partnumber){
     Map<String, Object> jsonDocument = new HashMap<String, Object>();
     jsonDocument.put("partid", partid);
     jsonDocument.put("partnumber", partnumber);
     return jsonDocument;
}

public void ESUpdate() {

    org.elasticsearch.node.Node node = org.elasticsearch.node.NodeBuilder.nodeBuilder().node();
    Client client = node.client();
    client.prepareIndex("soogrindex", "searchrow", "1")
    .setSource(putJsonDocument(1, "test55" )).execute().actionGet();

  } 



Exception in thread "main" java.lang.IllegalStateException: path.home is not configured
at org.elasticsearch.env.Environment.<init>(Environment.java:101)
at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:81)
at org.elasticsearch.node.Node.<init>(Node.java:128)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:152)
at com.example.GetSoogrSitemap.ESUpdate(GetSoogrSitemap.java:708)
at com.example.GetSoogrSitemap.main(GetSoogrSitemap.java:2056)


推荐答案

使用 NodeBuilder 只能连接到与您的程序在同一主机上运行的Elasticsearch服务器。您似乎试图从您的笔记本电脑或不在同一个QBox主机上的另一个主机连接到QBox上的集群。

Using NodeBuilder you can only connect to an Elasticsearch server running on the same host as your program. It seems you're trying to connect to a cluster on QBox from your laptop or another host not located on the same QBox host.

您应该尝试构建一个 TransportClient 代替,如下所示:

You should try building a TransportClient instead, like this:

Client client = TransportClient.builder().build()
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("your.qbox.host"), 9300));

这篇关于弹性搜索和连接到QBOX错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆