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

相关推荐
parafeeee2 小时前
程序人生-Hello’s P2P
数据库·后端·asp.net
bug攻城狮3 小时前
Spring Boot应用内存占用分析与优化
java·jvm·spring boot·后端
今天你TLE了吗3 小时前
JVM学习笔记:第八章——执行引擎
java·jvm·笔记·后端·学习
XPoet4 小时前
AI 编程工程化:Rule——给你的 AI 员工立规矩
前端·后端·ai编程
韩立学长4 小时前
基于Springboot校园志愿者服务平台77pz7812(程序、源码、数据库、调试部署方案及开发环境)系统界面展示及获取方式置于文档末尾,可供参考。
数据库·spring boot·后端
Java基基4 小时前
Spring让Java慢了30倍,JIT、AOT等让Java比Python快13倍,比C慢17%
java·开发语言·后端·spring
qq_12498707534 小时前
基于SpringBoot微信小程序的智能在线预约挂号系统(源码+论文+部署+安装)
spring boot·后端·微信小程序·毕业设计·计算机毕设·毕业设计源码
Victor3565 小时前
MongoDB(34)什么是聚合管道(Aggregation Pipeline)?
后端
Victor3565 小时前
MongoDB(35)聚合操作的常见阶段有哪些?
后端
追逐时光者5 小时前
2026年全面且实用的 Visual Studio 插件推荐,开发效率提升利器!
后端·visual studio