java.lang.NoSuchMethodError: 'co.elastic.clients.elasticsearch._types.KnnSearch$Builder co.elastic.clients.elasticsearch._types.KnnSearch$Builder.k(java.lang.Integer)'
Comment From: ElvisZhang0
upgrade your spring boot version like 3.3.10
Comment From: l-trotta
@lynickyoung either update spring boot to a version > 3.3.0, or force the elasticsearch-java to 8.13.3 or greater. As explained in the documentation, older versions of spring boot were still using a version of the elasticsearch java client where KnnSearch wasn't implemented
Comment From: bdgould
On a simple app with just these dependencies:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>24</java.version>
<spring-ai.version>1.0.0</spring-ai.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-openai</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-advisors-vector-store</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-chat-memory</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-vector-store-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.gitlab4j</groupId>
<artifactId>gitlab4j-api</artifactId>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>${spring-ai.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I seem to get a similar error though. I seem to see elasticsearch 8.18.1
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.ai.vectorstore.elasticsearch.ElasticsearchVectorStore.lambda$createIndexMapping$13(ElasticsearchVectorStore.java:334)
The following method did not exist:
'co.elastic.clients.elasticsearch._types.mapping.DenseVectorProperty$Builder co.elastic.clients.elasticsearch._types.mapping.DenseVectorProperty$Builder.similarity(java.lang.String)'
The calling method's class, org.springframework.ai.vectorstore.elasticsearch.ElasticsearchVectorStore, was loaded from the following location:
jar:file:/Users/ben.gould/.m2/repository/org/springframework/ai/spring-ai-elasticsearch-store/1.0.0/spring-ai-elasticsearch-store-1.0.0.jar!/org/springframework/ai/vectorstore/elasticsearch/ElasticsearchVectorStore.class
The called method's class, co.elastic.clients.elasticsearch._types.mapping.DenseVectorProperty$Builder, is available from the following locations:
jar:file:/Users/ben.gould/.m2/repository/co/elastic/clients/elasticsearch-java/8.18.1/elasticsearch-java-8.18.1.jar!/co/elastic/clients/elasticsearch/_types/mapping/DenseVectorProperty$Builder.class
The called method's class hierarchy was loaded from the following locations:
co.elastic.clients.elasticsearch._types.mapping.DenseVectorProperty.Builder: file:/Users/ben.gould/.m2/repository/co/elastic/clients/elasticsearch-java/8.18.1/elasticsearch-java-8.18.1.jar
co.elastic.clients.elasticsearch._types.mapping.PropertyBase.AbstractBuilder: file:/Users/ben.gould/.m2/repository/co/elastic/clients/elasticsearch-java/8.18.1/elasticsearch-java-8.18.1.jar
co.elastic.clients.util.WithJsonObjectBuilderBase: file:/Users/ben.gould/.m2/repository/co/elastic/clients/elasticsearch-java/8.18.1/elasticsearch-java-8.18.1.jar
co.elastic.clients.util.ObjectBuilderBase: file:/Users/ben.gould/.m2/repository/co/elastic/clients/elasticsearch-java/8.18.1/elasticsearch-java-8.18.1.jar