正在获取ElasticsearchStatusException和ElasticsearchResponseException?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了正在获取ElasticsearchStatusException和ElasticsearchResponseException?相关的知识,希望对你有一定的参考价值。
什么是ElasticsearchStatusException和ElasticsearchResponseException?
Caused by: org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=illegal_argument_exception, reason=request [/user_context/_refresh] contains unrecognized parameter: [ignore_throttled]]
Caused by: org.elasticsearch.client.ResponseException: method [POST], host [http://HOST_NAME:PORT], URI [/user_context/_refresh?ignore_throttled=false&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true], status line [HTTP/1.1 400 Bad Request]
这是我尝试运行JavaSpring代码时得到的,
ERROR 26299 --- [ main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : ElasticsearchStatusException[method [HEAD], host [] ...............
pom.xml中的ElasticSearch版本:6.8.1,带有Spring Data Elasticsearch版本:3.2.6
远程服务器的ElasticSearch版本:6.2.2
我正在使用High Level Rest Client。
@Override
@Bean
public RestHighLevelClient elasticsearchClient() {
final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo(elasticsearch_host + ":" + elasticsearch_port).build();
return RestClients.create(clientConfiguration).rest();
}
春季版:2.2.4
答案
看起来您是elasticsearch主机是空的,如以下错误所示:
AbstractElasticsearchRepository : failed to load elasticsearch nodes : ElasticsearchStatusException[method [HEAD], host []
如果您使用9200端口在本地运行Elasticsearch,则可以使用以下方式创建Rest高级客户端:
[AbstractElasticsearchRepository:无法加载elasticsearch节点:ElasticsearchStatusException [方法[HEAD],主机[]
import org.springframework.beans.factory.annotation.Autowired;@Configuration
static class Config {
@Bean
RestHighLevelClient client() {
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("localhost:9200")
.build();
return RestClients.create(clientConfiguration).rest();
}
}
以上是关于正在获取ElasticsearchStatusException和ElasticsearchResponseException?的主要内容,如果未能解决你的问题,请参考以下文章