问题如下:
{"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内容:
问题解决;(吐槽:代码让文言一心给的,真坑)