0

I am trying to insert data into ElasticSearch (version 7.4.2) hosted on bonsai.io cloud. When I try to create an IndexRequest & IndexResponse in my client code in Java (Java High Level REST client), there is no import available for both IndexRequest & IndexResponse.

My pom.xml has the following dependencies:

  <dependencies>
     <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>7.4.2</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.25</version>
    </dependency>

  </dependencies>

I even tried adding the below dependency to my pom.xml

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

Can somebody help me solve this issue in 7.4.2 version?

Amit
  • 30,756
  • 6
  • 57
  • 88
saurabhynwa
  • 51
  • 10
  • 1
    Create a [mcve], including code please – OneCricketeer Jan 29 '20 at 13:38
  • You mentioned kafka, though, so why not use Kafka Connect? – OneCricketeer Jan 29 '20 at 13:38
  • What do you mean by no import available, can you please share the screen-shot of these jars available in your class-path ? – Amit Jan 29 '20 at 14:13
  • 1
    I found the error and fixed it. 2 jar files; elasticsearch-7.4.2.jar & elasticsearch-rest-high-level-client-7.4.2.jar weren't accesible. So, I cleared the .m2 local cache and built my pom.xml again and it worked. Thank you @cricket_007 for your input. – saurabhynwa Jan 29 '20 at 17:03
  • @OpsterESNinja thank you for your input. I was able to fix the error. Reason is mentioned in the above comment. – saurabhynwa Jan 29 '20 at 17:06

2 Answers2

0

Please check this GitHub repo which is using ES 7.3 with java high-level rest client. You can change the ES client version in pom.xml and ready to go, as these are just minor version change, there isn't really any change in IndexRequest and indexResponse APIs.

Please see this of com.indore.GalaxyApp#createIndex method, where IndexRequest is created.

You can change your elasticsearch details config.yml and read the README section on how to start the app.

Let me know if you need more information.

Amit
  • 30,756
  • 6
  • 57
  • 88
0

Error occurred as the maven build was unable to read the jar manifest for following 2 jar files.

1) .m2/repository/org/elasticsearch/elasticsearch/7.4.2/elasticsearch-7.4.2.jar 2) .m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/7.4.2/elasticsearch-rest-high-level-client-7.4.2.jar

Solved the error by deleting the .m2 directory locally. Running the pom.xml after this as a maven build fixed the error and the above 2 jars were installed correctly.

saurabhynwa
  • 51
  • 10