我正在尝试连接到我的应用程序中的一个本地 ES 系统。以前它是一个不同的集群。最近,我们的 ES 团队将其迁移到启用了基本身份验证的不同集群。我编写了以下代码来初始化 HLRC。
final BasicCredentialsProvider basicCredentialsProvider = new BasicCredentialsProvider();
basicCredentialsProvider
.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("Username", "Password"));
RestClientBuilder builder = RestClient.builder(
new HttpHost(elasticSearchType.getHost(), 9200, "https"))
.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(
HttpAsyncClientBuilder httpClientBuilder) {
return httpClientBuilder
.setDefaultCredentialsProvider(basicCredentialsProvider);
}
});
return new RestHighLevelClient(builder);
我收到以下错误
reason=request [/index/_search] contains unrecognized parameters: [batched_reduce_size], [ccs_minimize_roundtrips], [ignore_throttled], [max_concurrent_shard_requests], [typed_keys]]
您能否建议我需要做什么才能连接到本地 ES?
请使用与es版本相同的依赖。在浏览器中输入http://127.0.0.1:9200/即可查看es版本
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>es version</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>es version</version>
<scope>compile</scope>
</dependency>