찾다

 >  Q&A  >  본문

elasticsearch java无法连接、

我在本地启动的ES,使用CURL进行调用是没问题的,但是在代码中无法连接。

 Settings settings = Settings.builder().put("cluster.name", "cluster-tony").build();
        try {
            //创建client
            TransportClient client = new PreBuiltTransportClient(settings)
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("192.168.0.230"), 9200));
            //搜索数据
            GetResponse response = client.prepareGet("blog", "article", "1").execute().actionGet();
            //输出结果
            System.out.println(response.getSourceAsString());
            //关闭client
            client.close();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }

在浏览器中访问的结果:

{
  "name" : "7BaVGc5",
  "cluster_name" : "cluster-tony",
  "cluster_uuid" : "ctTbTQfvTUyzV00JMWPfyA",
  "version" : {
    "number" : "5.3.0",
    "build_hash" : "3adb13b",
    "build_date" : "2017-03-23T03:31:50.652Z",
    "build_snapshot" : false,
    "lucene_version" : "6.4.1"
  },
  "tagline" : "You Know, for Search"
}
PHP中文网PHP中文网2804일 전493

모든 응답(1)나는 대답할 것이다

  • PHP中文网

    PHP中文网2017-04-18 10:57:35

    이유는 알겠는데요, 폼에 항아리가 중복되어 있어요

    회신하다
    0
  • 취소회신하다