0

I'm fairly new to ElasticSearch.

I have the data parsed and stored in a Java String in JSON format. I need to setup connection with AWS ElasticSearch and store the contents from the String into ElasticSearch using Java-API.

Following this and this post.

However, I'm getting confused in what's the best way to do this and which Java-ElasticSearch-API to use and how to use it.

Moreover, to set up the client connection and perform storing/retrieving data to/from ElasticSearch, which libraries should be imported into maven?

Any suggestions would be helpful.

1 Answer 1

0

I'm using spring-data-elasticsearch with spring boot, in this way you only need to add following dependency in maven:

<properties>
  <spring.boot.es.version>2.0.2.RELEASE</spring.boot.es.version>
  <elasticsearch.version>6.2.2</elasticsearch.version>
</properties>
<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.0.2.RELEASE</version>
  <relativePath/>
  <!-- lookup parent from repository -->
</parent>

<dependencies>
  <!--elasticsearch-->
  <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-elasticsearch</artifactId>
    <version>3.1.0.M3</version>
    <exclusions>
      <!-- here exclude default elasticsearch version because it's too old-->
      <exclusion>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
      </exclusion>
      <exclusion>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>transport</artifactId>
      </exclusion>
      <exclusion>
        <groupId>org.elasticsearch.plugin</groupId>
        <artifactId>transport-netty4-client</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
  <dependency>
    <groupId>org.elasticsearch.plugin</groupId>
    <artifactId>transport-netty4-client</artifactId>
    <version>${elasticsearch.version}</version>
  </dependency>
  <dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>${elasticsearch.version}</version>
  </dependency>
  <dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>transport</artifactId>
    <version>6.2.2</version>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    <exclusions>
      <exclusion>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
      </exclusion>
    </exclusions>
  </dependency>

  <dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.2</version>
  </dependency>
</dependencies>
Sign up to request clarification or add additional context in comments.

1 Comment

How do I set up the connection in Java using aws-java-sdk-elasticsearch API?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.