While I am able to connect for version es 7.17 but when I am doing the same for version 8.x I am unable to connect.
I have to connect to 8.x since I want to use KNN query which it seems is only available in 8.x and later versions.
Below is my Elasticsearch Config file while I am connecting to 7.17. What needs to be fixed or added in this so that I am able to connect to 8.x version since there is a requirement of username, password and ca_cert in that
package com.similarity.match.config;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ElasticsearchConfig {
@Value("${elasticsearch.host}")
private String host;
@Value("${elasticsearch.port}")
private int port;
@Value("${elasticsearch.scheme}")
private String scheme;
@Bean(destroyMethod = "close")
public RestHighLevelClient restHighLevelClient() {
return new RestHighLevelClient(
RestClient.builder(
new HttpHost(host, port, scheme)
).setHttpClientConfigCallback(httpAsyncClientBuilder ->
httpAsyncClientBuilder));
}
}
Also how can I write a knn query using Java RestHighLevelClient. Wasn't able to find any resource for the same online.