Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

My goal is to start a localhost elasticsearch node in my JUnit test, so I can index some docs and also test search queries through high-level rest client(e.g. making http calls to localhost ES node). I'm using Elasticsearch 6.2.

Here is the code I tried

    String clusterName = "test";

    Settings settings = Settings.builder()

            .put("path.home", ES_WORKING_DIR)

            .build();

    new Node(settings).start();

and this is the error message I got..

java.lang.IllegalStateException: Unsupported transport.type []

at __randomizedtesting.SeedInfo.seed([74752622FDACDD5:AB9FD863FD5A2A5F]:0)

at org.elasticsearch.common.network.NetworkModule.getTransportSupplier(NetworkModule.java:212)

at org.elasticsearch.node.Node.<init>(Node.java:427)

at org.elasticsearch.node.Node.<init>(Node.java:246)

at org.elasticsearch.node.Node.<init>(Node.java:242)

Basically, I'm not sure what parameters to set in Settings.

1 Answer

0 votes
by (44.4k points)

Use this:

Settings.Builder nodeSettings = Settings.builder()

            .put("cluster.name", "my-integration-test")

            .put("http.enabled", "true")

            .put("path.data", dataDirectory)

            .put("path.home", "/")

            .put("transport.type", "netty4")

            .put("network.host", "_local_")

            .put("transport.tcp.port", "19200-19400")

            .put("http.port", "19200-19400")

            .put("discovery.type", "single-node");

    LOG.info("Starting up embedded Elasticsearch");

    node = new LocalNode(nodeSettings.build());

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...