Describe the feature: Unable to create index using java rest high level client.
Elasticsearch version (bin/elasticsearch --version
): elasticsearch 6.2.4
Plugins installed: [] No
JVM version (java -version
): java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
OS version (uname -a
if on a Unix-like system): Linux hostname 4.4.0-1060-aws #69-Ubuntu SMP Sun May 20 13:42:07 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Description of the problem including expected versus actual behavior:
Steps to reproduce:
Please include a minimal but complete recreation of the problem, including
(e.g.) index creation, mappings, settings, query etc. The easier you make for
us to reproduce it, the more likely that somebody will take the time to look at it.
```
RestHighLevelClient restHighLevelClient = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9200)));
System.out.println(restHighLevelClient.info().getClusterName());
System.out.println(restHighLevelClient.info().getNodeName());
CreateIndexRequest indexRequest = new CreateIndexRequest("sample-index");
restHighLevelClient.indices().create(indexRequest); // exception
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.2.4</version>
</dependency>
**Provide logs (if relevant)**:
Cluster [elasticsearch]
77IuWZa
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:496)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.BootstrapMethodError: java.lang.NoSuchMethodError: org.elasticsearch.action.admin.indices.create.CreateIndexResponse.fromXContent(Lorg/elasticsearch/common/xcontent/XContentParser;)Lorg/elasticsearch/action/admin/indices/create/CreateIndexResponse;
at org.elasticsearch.client.IndicesClient.create(IndicesClient.java:77)
at com.example.elasticsearch.ElasticsearchApplication.main(ElasticsearchApplication.java:27)
... 6 more
Caused by: java.lang.NoSuchMethodError: org.elasticsearch.action.admin.indices.create.CreateIndexResponse.fromXContent(Lorg/elasticsearch/common/xcontent/XContentParser;)Lorg/elasticsearch/action/admin/indices/create/CreateIndexResponse;
at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:975)
at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1000)
at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1394)
at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1750)
at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477)
... 8 more
```
hi @blackOcean , we reserve github for confirmed bugs or feature requests. This doesn't seem like a bug to me, you most likely have an old version of the elasticsearch dependency in your classpath. Let's continue this discussion in our forums at https://discuss.elastic.co/. Thanks!
Hi @javanna
Sorry. But elasticsearch dependency are latest. I already mentioned that I am using 6.2.4.
I found the problem : elasticsearch rest high level client is not able to download elasticsearch dependeny as transitive dependency. We have to explicitly pass elasticsearch dependency in mvn pom.xml to make it work.
Solution : Add elasticsearch in pom.xml
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.2.4</version>
</dependency>
If anybody else encounters this problem with Gradle instead of Maven, you have to state the explicit elasticsearch version like this:
ext['elasticsearch.version'] = '6.3.0'
and remove spring-data-elasticsearch from your project or dependencies because it needs a lower version
Most helpful comment
Hi @javanna
Sorry. But elasticsearch dependency are latest. I already mentioned that I am using 6.2.4.
I found the problem : elasticsearch rest high level client is not able to download elasticsearch dependeny as transitive dependency. We have to explicitly pass elasticsearch dependency in mvn pom.xml to make it work.
Solution : Add elasticsearch in pom.xml