Error when close REST response

Hi, I am using Elastic sesarch 7.6.0 with REST Client API in spring-boot.

This is problem code.

CloseIndexResponse closeIndexResponse = 
                    client.indices().close(requestClose, RequestOptions.DEFAULT);

In this part, .close() occurs error.

Error message :

The method close(org.elasticsearch.client.indices.CloseIndexRequest, 
org.elasticsearch.client.RequestOptions) in the type IndicesClient is not applicable for the 
arguments (org.elasticsearch.action.admin.indices.close.CloseIndexRequest, 
org.elasticsearch.client.RequestOptions)

I referenced this.

AcknowledgedResponse closeIndexResponse = client.indices().close(request, 
RequestOptions.DEFAULT);

from https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-close-index.html

Is there any problem?

Welcome!

I think you might have different versions on the classpath.

When using springboot with
elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...

Basically you can put this in your pom.xml:

<properties>
  <elasticsearch.version>7.6.0<elasticsearch.version>
</properties>

See documentation here: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions

Thank you for answer.

I stated elasticsearch version in pom.xml like this :

<dependencies>
    <dependency>
    	    <groupId>org.elasticsearch</groupId>
    	    <artifactId>elasticsearch</artifactId>
    	    <version>7.6.0</version>
    </dependency>

    <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <!-- <version>6.4.3</version> --> => Leave it on during version change
            <version>7.6.0</version>
    </dependency>
</dependencies>

Do I have to use <property> tag instead of <version> tag?

I believe so.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.