0
votes

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");
2
Looks like a discrepancy in versions of elasticsearch used to compile/build project and used to run it - Ivan
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
@JavaGuy look at my answer. You need to upgrade the Core library. - LppEdd

2 Answers

2
votes

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'
0
votes
<!-- 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.