RestHighLevelClient 使用

2021-01-02  本文已影响0人  陌椰_5702

依赖包如下,可能会有冲突,选择适合自己的就好,当时调了两个小时,崩溃~~~

<dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <version>6.8.13</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
            <version>6.8.13</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>6.8.13</version>
        </dependency>

java代码

 public static final String IP ="localhost";
    public static final int PORT = 9233;

    public static void getConnection()  {

        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost(IP, PORT, "http")));
        System.out.println(client.toString());

    }

因为处理了很久,所以在此记录一下,其实很简单~~

上一篇下一篇

猜你喜欢

热点阅读