0

I'm using the High Level Rest client from java. Specific version is 6.6.1 against an ES v6.6.1

I'm getting the following error when I try to do a BulkRequest which are all IndexRequests

java.lang.NoSuchMethodError: org.elasticsearch.action.bulk.BulkRequest.pipeline()Ljava/lang/String;

Happy to file an issue, but was wondering if someone might know what's up in case it's a non issue.

Below is the code I'm using. Would appreciate if anyone knows what this error is.

I'm definitely using lib 6.6.1

compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.6.1'

Thanks

BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "changeme"));

RestClientBuilder builder = RestClient.builder(new HttpHost("asus.local", 9200))
    .setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
RestHighLevelClient client = new RestHighLevelClient(builder);
BulkRequest request = new BulkRequest();

String line;
while ((line = reader.readLine()) != null) {
  String[] split = line.split(",");
  Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(split[0]);
  Map< String, Object> jsonMap = new HashMap< String, Object>();
  jsonMap.put("valuedate", date);
  jsonMap.put("value", Double.valueOf(split[1]));
  IndexRequest indexRequest = new IndexRequest("my_index", "doc", String.valueOf(row))
      .source(jsonMap);
  request.add(indexRequest);
}

System.out.println("starting bulk call");
BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);
System.out.println("DONE");
Java Guy
  • 1,005
  • 14
  • 20
  • Looks like a discrepancy in versions of elasticsearch used to compile/build project and used to run it – Ivan Feb 28 '19 at 20:02
  • I thought that might be it, so I downloaded ES 6.6.1 before posting. I'm defo on ES 6.6.1 and here is my gradle dependency: compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.6.1' – Java Guy Feb 28 '19 at 20:10
  • @JavaGuy look at my answer. You need to upgrade the Core library. – LppEdd Feb 28 '19 at 20:11

2 Answers2

2

The

public String pipeline() {
    return globalPipeline;
}

method has been added on version 6.6 of the Elasticsearch Server module (GitHub file - 6.6 branch).

Be sure all the Elastic Search modules share the same version.
As you wrote the Rest Client is 6.6.1, I suspect the Server one is older than that (< 6.6).

You need

<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>6.6.1</version>
</dependency>

Or for Gradle

implementation 'org.elasticsearch:elasticsearch:6.6.1'
LppEdd
  • 20,274
  • 11
  • 84
  • 139
  • I was using compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.6.1' . I'll try to add the elasticsearch lib you mentioned thx – Java Guy Feb 28 '19 at 20:12
  • @JavaGuy that is **another module**. The one I posted is the **Core** one. And look for duplicates inside your "dependencies" block. – LppEdd Feb 28 '19 at 20:12
  • yes understood thx. I'm adding both the rest high level client and the core module, correct? – Java Guy Feb 28 '19 at 20:14
  • @JavaGuy yes, exactly. – LppEdd Feb 28 '19 at 20:14
  • that's it thx. dang - not happy since i wasted a bunch of time on it. it would be reasonable to assume that high rest client 6.6.1 would depend on core 6.6.1 would it not? Other products of ELK stack are all in sync version wise (ES, Kibana, LogStash etc). Thanks for your help – Java Guy Feb 28 '19 at 20:17
  • @JavaGuy I understand you're a bit angry. And yes, your assumption is correct. I think you're introducing an older version of the Core module with a transitive dependency, which is unknown to you. Try to run the Dependencies task (https://docs.gradle.org/current/userguide/inspecting_dependencies.html) and you'll see everything – LppEdd Feb 28 '19 at 20:20
  • Not angry just mildly annoyed. I hear you about transitive dependencies but I literally had no other dependencies related to elastic. sorry this didn't come out nicely . dependencies { implementation 'org.springframework.boot:spring-boot-starter-jdbc' implementation 'com.fasterxml.jackson.module:jackson-module-kotlin' implementation 'org.jetbrains.kotlin:kotlin-reflect' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' implementation 'org.elasticsearch:elasticsearch:6.6.1' implementation 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.6.1' } – Java Guy Feb 28 '19 at 20:27
  • before your help, i was just declaring the rest-high-level-client dependency only. running dependencies does indeed show something using 6.4.3 . +--- org.elasticsearch.client:elasticsearch-rest-high-level-client:6.6.1 | +--- org.elasticsearch:elasticsearch:6.6.1 -> 6.4.3 | | +--- org.elasticsearch:elasticsearch-core:6.4.3 | | +--- org.elasticsearch:elasticsearch-secure-sm:6.4.3 | | +--- org.elasticsearch:elasticsearch-x-content:6.4.3 | | | +--- org.elasticsearch:elasticsearch-core:6.4.3 – Java Guy Feb 28 '19 at 20:35
  • @JavaGuy post the full output in the question, I'm curious to read it – LppEdd Feb 28 '19 at 20:35
  • SO won't let me edit the question since its already answered. but you can look at here: https://www.dropbox.com/s/j769pmhjk18ciso/dependencies.txt?dl=0 Also, here is my build.gradle (there were nothing else making reference to elastic libs other than high rest client) https://www.dropbox.com/s/r9v8vj205juvdmr/build.gradle?dl=0 – Java Guy Feb 28 '19 at 20:51
  • @JavaGuy I suspect this is related to caching. See this question https://stackoverflow.com/questions/13565082/how-can-i-force-gradle-to-redownload-dependencies At work I usually use the "./gradlew build --refresh-dependencies" solution – LppEdd Feb 28 '19 at 21:01
  • @JavaGuy you can also check the SHA or MD5 of the Rest module POM file http://central.maven.org/maven2/org/elasticsearch/client/elasticsearch-rest-high-level-client/6.6.1/ If it is different there is something wrong – LppEdd Feb 28 '19 at 21:03
0
<!-- elasticsearch-rest-high-level-client -->
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>6.6.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>6.6.1</version>
    </dependency>

I solved this problem use these code.

Sunny
  • 1
  • 1