Elasticsearch RestClient version conflict

Hi,

I am using the following artifact: "org.elasticsearch.client" % "elasticsearch-rest-high-level-client" % "7.6.2"

And this high-level-client contains the RestClient class that only has the two following methods with signatures:

  • performRequestAsync(Request request, ResponseListener responseListener)
  • performRequestAsync(final NodeTuple<Iterator<Node>> nodeTuple, InternalRequest request, final FailureTrackingResponseListener listener)

But when I run the following code:

val client: RestClient = RestClient.builder(new HttpHost("myHost", 9201)).build()

    ElasticsearchSource
      .create(
        indexName = "myIndex",
        typeName = "_doc",
        query = """{"match_all": {}}"""
      )(client)
      .take(10)
      .map { msg =>
        println(s"js: ${msg.source}")
      }
      .runWith(
        Sink.ignore
      )

I get the following error:
java.lang.NoSuchMethodError: org.elasticsearch.client.RestClient.performRequestAsync(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lorg/apache/http/HttpEntity;Lorg/elasticsearch/client/ResponseListener;[Lorg/apache/http/Header;)V

That is because in the elasticsearch-rest-client:7.6.2 there is no such method with that signature.
This method with the asked signature was only available in elasticsearch-rest-client:6.3.1

I cannot revert back go version 6.3.1 since I need the 7.6.2 version in other places in my project.
Also I tested the 7.7.1 version and it too doesn’t have that method.

How can I get elasticsearch to work now?

Thanks,
Zarko

hi @zarko,

the alpakka connector for elasticsearch depends on "org.elasticsearch.client" % "elasticsearch-rest-client" % "6.3.1" which seems to be binary incompatible with the "elasticsearch-rest-high-level-client" % "7.6.2" artifact you mentioned.
I think an option is to help push the alpakka connector for elasticsearch foward and bump the dependency there so the new version uses a newer elasticsearch-rest-client. You could also consider building your own artifact with the connector as a fat jar with shaded dependencies (but I think that’s trickier, TBH).

Unfortunately, there’s not much more you can do if you need to use two versions of the same library that are not binary compatible.

Cheers,

Good news!

It appears someone already put together a PR to solve this issue.

That is actually great news :)
I hope this will be resolved soon

1 Like