NoSuchMethodError for org.elasticsearch.action.support.IndicesOptions.ignoreThrottled()

Hi,

I get the java.lang.NoSuchMethodError for org.elasticsearch.action.support.IndicesOptions.ignoreThrottled(), when I execute the the line client.search(searchRequest, RequestOptions.DEFAULT); in the following code. I am using the Elasticsearch API version 7.3.0.

What should I do to correct the issue?

RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
new HttpHost("localhost", 9200, "http"),
new HttpHost("localhost", 9201, "http")));

SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("connect200");
searchRequest.source(sourceBuilder);
SearchResponse resp = client.search(searchRequest, RequestOptions.DEFAULT);
client.close();

Exception details given below

Exception in thread "main" java.lang.NoSuchMethodError: org.elasticsearch.action.support.IndicesOptions.ignoreThrottled()Z
at org.elasticsearch.client.RequestConverters$Params.withIndicesOptions(RequestConverters.java:966)
at org.elasticsearch.client.RequestConverters.addSearchRequestParams(RequestConverters.java:417)
at org.elasticsearch.client.RequestConverters.search(RequestConverters.java:404)
at org.elasticsearch.client.RestHighLevelClient.lambda$search$2(RestHighLevelClient.java:932)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1450)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1424)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1394)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:930)
at ElasticSearchService.BuildJson(ElasticSearchService.java:253)
at ElasticSearchService.searchLog(ElasticSearchService.java:40)
at Program.main(Program.java:27)

POM File content for Elasticsearch given below

<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>transport</artifactId>
    <version>7.3.0</version>
</dependency>
		
<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>elasticsearch-rest-high-level-client</artifactId>
    <version>7.3.0</version>
</dependency>

Could you remove the transport lib from your pom and share the full pom.xml?

Full POM file attached. I have removed transport dependency. But I still get the issue.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-starter-parent</artifactId>
    		<version>2.1.2.RELEASE</version>
    		<relativePath /> <!-- lookup parent from repository -->
    	</parent>
      <groupId>org.springframework.samples</groupId>
      <artifactId>TestMavenYY</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      
      <properties>

    		<!-- Generic properties -->
    		<java.version>1.8</java.version>
    		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    		

    	

    	</properties>
    	
    	<dependencies>
    		<!-- Spring and Transactions -->
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-context</artifactId>
    		
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-tx</artifactId>
    			
    		</dependency>
    		
    <dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-web</artifactId>
    			
    		</dependency>
    		

    		<!-- Logging with SLF4J & LogBack -->
    		<dependency>
    			<groupId>org.slf4j</groupId>
    			<artifactId>slf4j-api</artifactId>
    		
    			<scope>compile</scope>
    		</dependency>
    		<dependency>
    			<groupId>ch.qos.logback</groupId>
    			<artifactId>logback-classic</artifactId>
    			
    			<scope>runtime</scope>
    		</dependency>

    		<!-- Hibernate -->
    		<dependency>
    			<groupId>org.hibernate</groupId>
    			<artifactId>hibernate-entitymanager</artifactId>
    			
    		</dependency>

    		
    		<!-- Test Artifacts -->
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-test</artifactId>
    			
    			<scope>test</scope>
    		</dependency>
    		<dependency>
    			<groupId>junit</groupId>
    			<artifactId>junit</artifactId>
    			
    			<scope>test</scope>
    		</dependency>
    		<dependency>
    			<groupId>com.siemens.mindsphere</groupId>
    			<artifactId>mindsphere-sdk</artifactId>
    			<version>1.1.0</version>
    		</dependency>
    		<dependency>
                     <groupId>com.siemens.mindsphere</groupId>
                     <artifactId>mindsphere-sdk</artifactId>
                     <version>1.2.1</version>
                 </dependency>
    		
    		
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-core</artifactId>
    		
    		
    		</dependency>
    		<dependency>
    		    <groupId>com.google.code.gson</groupId>
    		    <artifactId>gson</artifactId>
    		    
    		</dependency>
    		
    		<dependency>
    		    <groupId>com.rabbitmq</groupId>
    		    <artifactId>amqp-client</artifactId>
    		    
    		</dependency>
    		<dependency>
    		   <groupId>org.glassfish</groupId>
    		   <artifactId>javax.json</artifactId>
    		   <version>1.1.4</version>
    		</dependency>
    		
    		
    		<dependency>
        		<groupId>org.elasticsearch.client</groupId>
        		<artifactId>elasticsearch-rest-high-level-client</artifactId>
        		<version>7.2.0</version>
    		</dependency>
    		

    	</dependencies>	
    </project>

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.3.0<elasticsearch.version>
</properties>

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

Might not be the problem here though.

Thanks David. It worked!

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