Migrating from Elastic Node Client to Transport or Rest Client












0















Our current application is running under Spring Boot 1.5 (comes with Elastic Search 2.X)



We use Embedded/In-Memory Elastic search instance and use Node client to connect to the Embedded/In-Memory Elastic instance.



We are looking to migrate away from Embedded Elastic Search to external Elastic Search Instance.



This means we'll need to migrate away from Node Client and use either
Transport Client or Low-Level-Rest-Client or High-Level-Rest-Client



Our Spring Boot Config for Node Client looks like this:



@Configuration

@EnableElasticsearchRepositories
public class ElasticConfiguration {

@Bean
NodeBuilder nodeBuilder(){ return new NodeBuilder(); }

@Bean
public ElasticsearchOperations elasticsearchTemplate() throws IOException {

File tmpDir = File.createTempFile("elastic") );

Settings.Builder elasticsearchSettings = Settings.settingsBuilder()
.put("http.enabled", "true") // 1
.put("index.number_of_shards", "1")
.put("path.data", new File(tmpDir, "data").getAbsolutePath())
.put("path.logs", new File(tmpDir, "logs").getAbsolutePath())
.put("path.work", new File(tmpDir, "work").getAbsolutePath())
.put("path.home", tmpDir);
return new ElasticsearchTemplate(nodeBuilder().local(true)
.settings(elasticsearchSettings.build())
.node()
.client());
}


Question:



1) If we migrate from Elastic Node client to Elastic Transport client, will it mean heavy code changes for the currently coded Elastic pieces
(outside of the elastic config class that creates node client)



2) If we migrate from Node Client to Using Rest Client:
i) Again, outside of the Elastic Config code changes, will it mean heavy code changes for the currently coded Elastic pieces?
ii) How would the above SpringBoot Elastic Config for Rest client look like? any sample code?










share|improve this question



























    0















    Our current application is running under Spring Boot 1.5 (comes with Elastic Search 2.X)



    We use Embedded/In-Memory Elastic search instance and use Node client to connect to the Embedded/In-Memory Elastic instance.



    We are looking to migrate away from Embedded Elastic Search to external Elastic Search Instance.



    This means we'll need to migrate away from Node Client and use either
    Transport Client or Low-Level-Rest-Client or High-Level-Rest-Client



    Our Spring Boot Config for Node Client looks like this:



    @Configuration

    @EnableElasticsearchRepositories
    public class ElasticConfiguration {

    @Bean
    NodeBuilder nodeBuilder(){ return new NodeBuilder(); }

    @Bean
    public ElasticsearchOperations elasticsearchTemplate() throws IOException {

    File tmpDir = File.createTempFile("elastic") );

    Settings.Builder elasticsearchSettings = Settings.settingsBuilder()
    .put("http.enabled", "true") // 1
    .put("index.number_of_shards", "1")
    .put("path.data", new File(tmpDir, "data").getAbsolutePath())
    .put("path.logs", new File(tmpDir, "logs").getAbsolutePath())
    .put("path.work", new File(tmpDir, "work").getAbsolutePath())
    .put("path.home", tmpDir);
    return new ElasticsearchTemplate(nodeBuilder().local(true)
    .settings(elasticsearchSettings.build())
    .node()
    .client());
    }


    Question:



    1) If we migrate from Elastic Node client to Elastic Transport client, will it mean heavy code changes for the currently coded Elastic pieces
    (outside of the elastic config class that creates node client)



    2) If we migrate from Node Client to Using Rest Client:
    i) Again, outside of the Elastic Config code changes, will it mean heavy code changes for the currently coded Elastic pieces?
    ii) How would the above SpringBoot Elastic Config for Rest client look like? any sample code?










    share|improve this question

























      0












      0








      0








      Our current application is running under Spring Boot 1.5 (comes with Elastic Search 2.X)



      We use Embedded/In-Memory Elastic search instance and use Node client to connect to the Embedded/In-Memory Elastic instance.



      We are looking to migrate away from Embedded Elastic Search to external Elastic Search Instance.



      This means we'll need to migrate away from Node Client and use either
      Transport Client or Low-Level-Rest-Client or High-Level-Rest-Client



      Our Spring Boot Config for Node Client looks like this:



      @Configuration

      @EnableElasticsearchRepositories
      public class ElasticConfiguration {

      @Bean
      NodeBuilder nodeBuilder(){ return new NodeBuilder(); }

      @Bean
      public ElasticsearchOperations elasticsearchTemplate() throws IOException {

      File tmpDir = File.createTempFile("elastic") );

      Settings.Builder elasticsearchSettings = Settings.settingsBuilder()
      .put("http.enabled", "true") // 1
      .put("index.number_of_shards", "1")
      .put("path.data", new File(tmpDir, "data").getAbsolutePath())
      .put("path.logs", new File(tmpDir, "logs").getAbsolutePath())
      .put("path.work", new File(tmpDir, "work").getAbsolutePath())
      .put("path.home", tmpDir);
      return new ElasticsearchTemplate(nodeBuilder().local(true)
      .settings(elasticsearchSettings.build())
      .node()
      .client());
      }


      Question:



      1) If we migrate from Elastic Node client to Elastic Transport client, will it mean heavy code changes for the currently coded Elastic pieces
      (outside of the elastic config class that creates node client)



      2) If we migrate from Node Client to Using Rest Client:
      i) Again, outside of the Elastic Config code changes, will it mean heavy code changes for the currently coded Elastic pieces?
      ii) How would the above SpringBoot Elastic Config for Rest client look like? any sample code?










      share|improve this question














      Our current application is running under Spring Boot 1.5 (comes with Elastic Search 2.X)



      We use Embedded/In-Memory Elastic search instance and use Node client to connect to the Embedded/In-Memory Elastic instance.



      We are looking to migrate away from Embedded Elastic Search to external Elastic Search Instance.



      This means we'll need to migrate away from Node Client and use either
      Transport Client or Low-Level-Rest-Client or High-Level-Rest-Client



      Our Spring Boot Config for Node Client looks like this:



      @Configuration

      @EnableElasticsearchRepositories
      public class ElasticConfiguration {

      @Bean
      NodeBuilder nodeBuilder(){ return new NodeBuilder(); }

      @Bean
      public ElasticsearchOperations elasticsearchTemplate() throws IOException {

      File tmpDir = File.createTempFile("elastic") );

      Settings.Builder elasticsearchSettings = Settings.settingsBuilder()
      .put("http.enabled", "true") // 1
      .put("index.number_of_shards", "1")
      .put("path.data", new File(tmpDir, "data").getAbsolutePath())
      .put("path.logs", new File(tmpDir, "logs").getAbsolutePath())
      .put("path.work", new File(tmpDir, "work").getAbsolutePath())
      .put("path.home", tmpDir);
      return new ElasticsearchTemplate(nodeBuilder().local(true)
      .settings(elasticsearchSettings.build())
      .node()
      .client());
      }


      Question:



      1) If we migrate from Elastic Node client to Elastic Transport client, will it mean heavy code changes for the currently coded Elastic pieces
      (outside of the elastic config class that creates node client)



      2) If we migrate from Node Client to Using Rest Client:
      i) Again, outside of the Elastic Config code changes, will it mean heavy code changes for the currently coded Elastic pieces?
      ii) How would the above SpringBoot Elastic Config for Rest client look like? any sample code?







      elasticsearch






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 3:59









      user3216514user3216514

      72110




      72110
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Without any look on your code, based on my experience:



          1) should work with minor or no changes at all. But you'll have to go with the rest client as the transport client will be removed soon. Or you'll have work again here in the future.



          2i) it depends on the features you are using currently



          2ii) please see https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.5/java-rest-high-level-migration.html



          I've done many such migrations, many of them are nearly painless. But it really depends on the code of your app. If you can switch to the high-level client there should be just minor changes in your code. But there are also few features missing in the rest client at this moment (you're probably not using). If you need to use the low-level client (due to a jvm version incompatibility) your changes will be a lot more as there is a different approach needed: you need to generate your json for requests and unmarshall the responses.



          Please consider your development profile and your tests too. Probably there is an embedded node starting with your application? If so, this needs to be solved in a different way.



          If you encounter any migration problems, feel free to come back here again. We'll be here :D






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423682%2fmigrating-from-elastic-node-client-to-transport-or-rest-client%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Without any look on your code, based on my experience:



            1) should work with minor or no changes at all. But you'll have to go with the rest client as the transport client will be removed soon. Or you'll have work again here in the future.



            2i) it depends on the features you are using currently



            2ii) please see https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.5/java-rest-high-level-migration.html



            I've done many such migrations, many of them are nearly painless. But it really depends on the code of your app. If you can switch to the high-level client there should be just minor changes in your code. But there are also few features missing in the rest client at this moment (you're probably not using). If you need to use the low-level client (due to a jvm version incompatibility) your changes will be a lot more as there is a different approach needed: you need to generate your json for requests and unmarshall the responses.



            Please consider your development profile and your tests too. Probably there is an embedded node starting with your application? If so, this needs to be solved in a different way.



            If you encounter any migration problems, feel free to come back here again. We'll be here :D






            share|improve this answer






























              0














              Without any look on your code, based on my experience:



              1) should work with minor or no changes at all. But you'll have to go with the rest client as the transport client will be removed soon. Or you'll have work again here in the future.



              2i) it depends on the features you are using currently



              2ii) please see https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.5/java-rest-high-level-migration.html



              I've done many such migrations, many of them are nearly painless. But it really depends on the code of your app. If you can switch to the high-level client there should be just minor changes in your code. But there are also few features missing in the rest client at this moment (you're probably not using). If you need to use the low-level client (due to a jvm version incompatibility) your changes will be a lot more as there is a different approach needed: you need to generate your json for requests and unmarshall the responses.



              Please consider your development profile and your tests too. Probably there is an embedded node starting with your application? If so, this needs to be solved in a different way.



              If you encounter any migration problems, feel free to come back here again. We'll be here :D






              share|improve this answer




























                0












                0








                0







                Without any look on your code, based on my experience:



                1) should work with minor or no changes at all. But you'll have to go with the rest client as the transport client will be removed soon. Or you'll have work again here in the future.



                2i) it depends on the features you are using currently



                2ii) please see https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.5/java-rest-high-level-migration.html



                I've done many such migrations, many of them are nearly painless. But it really depends on the code of your app. If you can switch to the high-level client there should be just minor changes in your code. But there are also few features missing in the rest client at this moment (you're probably not using). If you need to use the low-level client (due to a jvm version incompatibility) your changes will be a lot more as there is a different approach needed: you need to generate your json for requests and unmarshall the responses.



                Please consider your development profile and your tests too. Probably there is an embedded node starting with your application? If so, this needs to be solved in a different way.



                If you encounter any migration problems, feel free to come back here again. We'll be here :D






                share|improve this answer















                Without any look on your code, based on my experience:



                1) should work with minor or no changes at all. But you'll have to go with the rest client as the transport client will be removed soon. Or you'll have work again here in the future.



                2i) it depends on the features you are using currently



                2ii) please see https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.5/java-rest-high-level-migration.html



                I've done many such migrations, many of them are nearly painless. But it really depends on the code of your app. If you can switch to the high-level client there should be just minor changes in your code. But there are also few features missing in the rest client at this moment (you're probably not using). If you need to use the low-level client (due to a jvm version incompatibility) your changes will be a lot more as there is a different approach needed: you need to generate your json for requests and unmarshall the responses.



                Please consider your development profile and your tests too. Probably there is an embedded node starting with your application? If so, this needs to be solved in a different way.



                If you encounter any migration problems, feel free to come back here again. We'll be here :D







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 22 '18 at 14:53

























                answered Nov 22 '18 at 8:24









                ibexitibexit

                760413




                760413






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423682%2fmigrating-from-elastic-node-client-to-transport-or-rest-client%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Wiesbaden

                    Marschland

                    Dieringhausen