Es 参数不匹配问题illegal_argument_exception

问题如下:

{"type":"illegal_argument_exception","reason":"request [/] contains unrecognized parameters: [allow_no_indices], [expand_wildcards], [ignore_unavailable], [master_timeout]"}],"type":"illegal_argument_exception","reason":"request [/] contains unrecognized parameters: [allow_no_indices], [expand_wildcards], [ignore_unavailable], [master_timeout]"},"status":400}

首先确认自己的版本是没有问题的,其他很多都是这么解决的,但我的这里不是,原因如下:

原代码如下:

        GetIndexRequest getIndexRequest = new GetIndexRequest();
        try {
            GetIndexResponse getIndexResponse = client.indices().get(getIndexRequest, RequestOptions.DEFAULT);
            String[] indices = getIndexResponse.getIndices();
            for (String index : indices) {
                System.out.println(index);
            }
        } catch (IOException e) {
            throw new RuntimeException("Failed to get indices", e);
        }

问题在于发送请求时,会使用getIndexRequest中indices,像这样不写的话就是空,那么发送的请求就是
在这里插入图片描述

这个请求就不是和索引有关的请求了,获取的是ES的相关信息

在postman中直接发送**“/”**请求,这个肯定就不需要上面那些参数了:
在这里插入图片描述

然后修改代码,增加indices内容:

在这里插入图片描述

问题解决;(吐槽:代码让文言一心给的,真坑)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值