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

相关推荐
tachibana27 分钟前
Go 语言的 Map 是否是并发安全的?
开发语言·数据结构·后端·golang·go·语言
dd聊技术9 分钟前
发布前的那十几秒:AI 预检为什么不用「主编 Agent」
后端
Bazingga14 分钟前
LLM记忆实战:从一次164秒慢问,到上下文治理与记忆版图
后端
看浪的路人17 分钟前
第8讲:RAG 生产化——Go 实现亿级向量召回 + 混合检索 + 重排序 Pipeline
开发语言·后端·golang
tachibana218 分钟前
Go 语言 Map 的扩容过程是怎样的?
开发语言·后端·golang·go·语言
念何架构之路21 分钟前
go-grpc服务端调用链
开发语言·后端·golang
羑悻27 分钟前
atomic凭什么线程安全?无锁编程为何有时比锁还慢?C++高并发必懂的原子操作真相!
后端
SamDeepThinking29 分钟前
synchronized 和 lock 有什么区别?
java·后端·面试
m0_5873830035 分钟前
无人自助拼豆系统的全栈开发方案
java·后端·struts·小程序·架构
Profile排查笔记1 小时前
浏览器多开怎么设置独立 IP?Profile、代理与核验流程
前端·人工智能·后端·自动化