文档

    https://www.elastic.co/guide/index.html
    https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-getting-started.html
    image.png
    image.png
    image.png
    1.导入依赖

    1. <dependency>
    2. <groupId>org.elasticsearch.client</groupId>
    3. <artifactId>elasticsearch-rest-high-level-client</artifactId>
    4. <version>7.9.1</version>
    5. </dependency>

    2.构建对象
    image.png
    创建项目

    image.png
    image.png
    配置基本的项目
    问题:一定要保证,我们导入的依赖和我们的es版本一致
    image.png
    编写配置类

    1. @Configuration
    2. public class ElasticSearchClientConfig {
    3. @Bean
    4. public RestHighLevelClient restHighLevelClient(){
    5. RestHighLevelClient client = new RestHighLevelClient(
    6. RestClient.builder(
    7. new HttpHost("localhost", 9200, "http")));
    8. return client;
    9. }
    10. }