Is REST Client for Elasticsearch the only way to go in the future?


(Ong) #1

I recently attended an Elasticsearch Developers course and understand that the Java API will be dropped in the near future and the Java REST client is the way to go.

A Elasticsearch blog post seemed to confirm this too:
State of Official Elasticsearch Java Clients

What about other clients like JavaScript API or the .NET API? Are they also at risk of being dropped?

Will the Java REST client be the only way to develop for ES?


(Christoph) #2

No, this has nothing to do with other clients like JavaScript API or the .NET API. Also, the new high level rest client will only be the java rest client that will be developed as part of the Elasticsearch project, but there are already other java rest clients out there (like the popular Jest client) that you can use. However, we hope that over time users will use the new Elasticsearch Java rest and that by further development and contributions by the community we can make it the best maintained client for Java users.


(Dan Markhasin) #3

@cbuescher, the blog post linked by OP states:

"As soon as the REST client is feature complete and is mature enough to replace the Java API entirely, we will deprecate and finally remove the transport client and the Java API."

Is this still true? Are you still planning to remove the transport client in the long term?


(Christoph) #4

Yes, that is still the plan.


(Dan Markhasin) #5

Where can I find the high level rest client? The documentation points to the following artifact:

org.elasticsearch.client elasticsearch-rest-high-level-client 6.0.0-alpha2

But I can't find this artifact in Maven..


(Christoph) #6

Hi,

the high level client will only be released with 6.0.0-beta1. The reason its already in the alpha2 docs is because we build them directly out of the master branch. There is a short note at the top of https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high.html which is supposed as a hint for that, but I understand it can be confusing.


(Rohit Khatkar) #7

Is there any way get the alpha release jar or dependency.

I read on Elastic Search blog that Low level rest api is compatible with all Elastic Search client.

RestHighLevelClient client =
new RestHighLevelClient(lowLevelRestClient);

High level rest uses low level rest client, does it mean high level rest client is compatible with all version ?

Please provide us the high level alpha release as I am implementing the same functionality myself.


(Christoph) #8

I'm afraid, until either ES 5.6 or 6.0.0-beta1 you will be release you will need to build the jar yourself using the respective 5.6 or master branch of the source code.

No, the High-Level client currently depends on a fixed version of ES (>5.6), mainly to use the same query, aggs builders etc... that the current transport client uses to make the transition there easy (https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.0/java-rest-high-compatibility.html)


(David Pilato) #9

That's actually possible with the SNAPSHOT versions.

See

I prepared the migration for my project here: https://github.com/dadoonet/fscrawler/pull/417

Just waiting for the release :slight_smile:


(Christoph) #10

Thanks @dadoonet, good to know. I missed that.


(Rohit Khatkar) #11

Thanks @cbuescher , I use AWS Elastic-search and AWS uses older version so I will not be able to High Level Rest Client. AWS is still at 5.3 only.


(Christoph) #12

T[quote="khatkarrohit, post:11, topic:93233"]
AWS uses older version so I will not be able to High Level Rest Client. AWS is still at 5.3 only
[/quote]

That depends, I would give it a try. After all, you would run the HL client in your application, and it talks via REST with the cluster. So if the cluster is 5.3, you are running e.g. 5.6 in your client app you should be fine. Changes in the REST Api shouldn't happen in minor versions. I don't know if there are other considerations but if you can I'd try it out.


(Rohit Khatkar) #13

@cbuescher I will give it a try once it is released in Maven repo.

Low level rest client is compatible with all versions and High level rest client uses Low level internally. So high level rest client should be fine with older version that work with Low level rest client.


(Rohit Khatkar) #14

I tried beta1 but when I include High level rest client in spring boot application than it gives some Class not found exception.

Caused by: java.lang.ClassNotFoundException: org.elasticsearch.common.xcontent.NamedXContentRegistry

If I add Elaticsearch as dependency than it gives another error:

Caused by: java.lang.ClassNotFoundException: org.apache.lucene.util.Version

I tried building last month from snapshot version but it created a dependency hell. Still with beta version it has same issues.

My maven:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.json/javax.json-api -->
    <dependency>
        <groupId>javax.json</groupId>
        <artifactId>javax.json-api</artifactId>
        <version>1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.glassfish/javax.json -->
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.json</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>6.0.0-beta1</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>6.0.0-beta1</version>
    </dependency>
</dependencies>

Spring Bean creation:

    @Bean
    @Qualifier("resthighlevel")
    public RestHighLevelClient restHighLevelClient() throws Exception {
        RestClient restClient = RestClient.builder(new HttpHost(esHost, 443,  "https")).build();
        RestHighLevelClient client = new RestHighLevelClient(restClient);
        return client;
    }

(David Pilato) #15

I think you are hitting this:

Add this repository:

        <repository>
            <id>elastic-lucene-snapshots</id>
            <name>Elastic Lucene Snapshots</name>
            <url>http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/00142c9</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>

(system) #16

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.