简体   繁体   中英

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

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");

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM