美文网首页
RestHighLevelClient 使用

RestHighLevelClient 使用

作者: 陌椰_5702 | 来源:发表于2021-01-02 23:12 被阅读0次

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

<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());

    }

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

相关文章

网友评论

      本文标题:RestHighLevelClient 使用

      本文链接:https://www.haomeiwen.com/subject/dibyoktx.html