Search code examples
javaelasticsearchelasticsearch-7resthighlevelclient

How do we create an IndexRequest in Java for ElasticSearch 7.4.2 Java High Level REST Client?


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?


Solution

  • 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.