Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch 5 create in memory node for testing

I'm migrating to Elasticsearch 5 from 2 and we have integration tests which run on build servers which do not have ES nodes available. We have used the NodeBuilder from the previous version of ES to create in memory nodes on demand, but I can't find how to do the same thing with version 5.

like image 682
pacitu Avatar asked Oct 31 '16 13:10

pacitu


2 Answers

First time posting in stack overflow, sorry if any mistake in how ask my question.

I had exactly the same problem where I start a client in memory, but I could not connect using the transport client having NoNodeAvailableException as error message.

    Settings settings = Settings.builder()
            .put("path.home", "target/elasticsearch")
            .put("transport.type", "local")
            .put("http.enabled", false)
            .build();

    node = new Node(settings).start();

Now in my test I inject node().client() to the repository and it worked.

For whole code, spring boot and ES 5 without spring-data which does not support ES 5: https://github.com/jomilanez/elastic5

like image 73
josiane Avatar answered Nov 08 '22 17:11

josiane


NodeBuilder is removed from the API in ES 5 and the same thing can be achieved adding "transport.type" "local" to the settings and creating a node with

new Node(settings).start().client()

like image 40
pacitu Avatar answered Nov 08 '22 18:11

pacitu