RestHighLevelClient giving "unrecognized parameters" when trying to send request to ElasticSearch

34 views Asked by At

I am trying to connect to one of the on-prem ES system in my application. Previously it was a different cluster. Recently, our ES team migrated it to a different cluster with basic auth enabled. I have written the below code for initializing 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);

I am getting the below error

 reason=request [/index/_search] contains unrecognized parameters: [batched_reduce_size], [ccs_minimize_roundtrips], [ignore_throttled], [max_concurrent_shard_requests], [typed_keys]]

Could you please suggest what I need to do to connect with the on-prem ES?

1

There are 1 answers

0
juvenile On

Please use the same dependency as the es version. Enter http://127.0.0.1:9200/ in the browser to see the es version.

<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>