且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何配置弹性搜索5

更新时间:2023-02-18 23:37:09

是的,你可以在 5.0的官方文档以及

 设置设置= Settings.builder()
.put(cluster.name,ElasticSearchClusterName);

TransportClient client = new PreBuiltTransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host1),9300))
.addTransportAddress(new InetSocketTransportAddress(InetAddress。 getByName(host2),9300));

没有什么是 PreBuiltTransportClient $ b


  • Netty3

  • Netty4

  • Reindex

  • Percolator

  • 胡子



还要确保你依赖于运输工件:

 <依赖性> 
< groupId> org.elasticsearch.client< / groupId>
< artifactId> transport< / artifactId>
< version> 5.0.0-beta1< / version>
< / dependency>


How to configure elasticsearch 5 TransportClient.

Now TransportClient is abstract class. I found only PreBuiltTransportClient, this is the new way to configure elasticsearch Client ?

Yes, you can find that in the official documentation for 5.0 as well

Settings settings = Settings.builder()
   .put("cluster.name", "ElasticSearchClusterName");

TransportClient client = new PreBuiltTransportClient(settings)
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host1"), 9300))
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host2"), 9300));

It is worth nothing that the PreBuiltTransportClient is pre-configured with the following modules:

  • Netty3
  • Netty4
  • Reindex
  • Percolator
  • Mustache

Also make sure that you have a dependency on the transport artifact:

<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>transport</artifactId>
    <version>5.0.0-beta1</version>
</dependency>