java.lang.NoSuchMethodError: org.elasticsearch.action.index.IndexRequest.ifSeqNo()J

在我使用elasticsearch-rest-high-level-client7.0版本连接elasticsearch7.0的时候使用官网提供的示例:
IndexRequest indexRequest = new IndexRequest("pubmed2","_doc","2").source(jsonMap);
var indexResponse = restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
他发生java.lang.NoSuchMethodError: org.elasticsearch.action.index.IndexRequest.ifSeqNo()J错误,
模板已经建好:
{
"mapping": {
"properties": {
"id": {
"type": "integer"
}
}
}
}

If using any dependency tool follow below steps:

  1. Exclude "groupd Id: org.elasticsearch artifactId:elasticsearch ", "groupId: org.elasticsearch.client artifactId:elasticsearch-rest-client " from elasticsearch-rest-high-level-client(as it loads 6.4.3 version of these jars)

  2. Add dependencies for above two excluded jars with verion 7.0.0 and build.

Are you using spring boot?

Yes I had this issue with Spring boot.

Next time, provide more context. That will help to get a faster answer.

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

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

1 Like

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