Java RestClient创建索引报错:java.net.SocketTimeoutException: 30,000 milliseconds timeo

发生背景

编写测试类准备创建索引库

java 复制代码
import static cn.itcast.hotel.constants.HotelConstants.MAPPING_TEMPLATE;

@SpringBootTest
class HotelAdminApplicationTests {

    private RestHighLevelClient client;

    @BeforeEach
    void setUp(){
        this.client = new RestHighLevelClient(RestClient.builder(
                HttpHost.create("http://127.0.0.1:9200")
        ));
    }

    @AfterEach
    void tearDown() throws IOException {
        this.client.close();
    }

    @Test
    void contextLoads() {
        System.out.println(client);
    }

    @Test
    void createHotelIndex() throws IOException {
        // 创建Request对象
        CreateIndexRequest request = new CreateIndexRequest("hotel");
        // 准备请求的参数:DSL
        request.source(MAPPING_TEMPLATE, XContentType.JSON);
        // 发送请求
        client.indices().create(request, RequestOptions.DEFAULT);
    }

}

解决方案

改索引库名字:hotel->hotel_index

相关推荐
看到我,请让我去学习2 小时前
数据结构—排序(斐波那契数列,冒泡,选择,插入,快速,归并,图,广度优先算法)
c语言·开发语言·数据结构·后端
源码云商4 小时前
基于Spring Boot + Vue的教师工作量管理系统设计与实现
vue.js·spring boot·后端
why1517 小时前
深信服golang面经
开发语言·后端·golang
言之。7 小时前
Go语言中new与make的深度解析
开发语言·后端·golang
田秋浩8 小时前
Springboot 跨域拦截器配置说明
java·spring boot·后端
汇匠源9 小时前
Spring Boot + +小程序, 快速开发零工市场小程序
spring boot·后端·小程序
码农爱java9 小时前
Elasticsearch 深入分析三种分页查询【Elasticsearch 深度分页】
java·大数据·spring boot·后端·elasticsearch·全文检索
黄暄10 小时前
Spring Boot 登录实现:JWT 与 Session 全面对比与实战讲解
javascript·网络·spring boot·后端
设计师小聂!10 小时前
Spring ---IOC容器和DI的具体应用
java·后端·spring
我命由我1234511 小时前
IDEA - Windows IDEA 代码块展开与折叠(基础折叠操作、高级折叠操作)
java·笔记·后端·java-ee·intellij-idea·学习方法·intellij idea