Elasticsearch 6.2 start a localhost http node in unit test
These are no longer supported by elastic, but they work for Junit test purposes
I have the following
For 5.6.7
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(), Arrays.asList(Netty4Plugin.class, ReindexPlugin.class)); node.start();
For elastic 6.8.3
Settings.Builder nodeSettings = Settings.builder() .put("cluster.name", "integration-test") .put("node.name", "node-test") .put("path.data", dataDirectory) .put("path.home", "/") .put("transport.type", "netty4") .put("network.host", "127.0.0.1") .put("http.port", "19200"); LOG.info("Starting up embedded Elasticsearch"); node = new LocalNode(nodeSettings.build(), Arrays.asList(Netty4Plugin.class, ReindexPlugin.class, CommonAnalysisPlugin.class)); node.start();
where
private static class LocalNode extends Node { LocalNode(Settings settings, Collection<Class<? extends Plugin>> classpathPlugins) { super(new Environment(settings, null), classpathPlugins, true); } @Override protected void registerDerivedNodeNameWithLogger(final String s) {}}
For 6.8.x you will need
<dependency> <groupId>org.codelibs.elasticsearch.module</groupId> <artifactId>analysis-common</artifactId> <version>6.8.2</version> </dependency>