Reputation: 67
I have an elastic search cluster with two master nodes and two data nodes. And I need to connect to an elastic search cluster with two master nodes from spring boot.
Is anybody knows how to connect the multinode elastic search cluster from spring boot?
Upvotes: 3
Views: 970
Reputation: 32386
In Elasticsearch cluster you can connect to any node ip and that node will forward the request to other nodes in the Elasticsearch cluster, but this is not a ideal way of connecting to Elasticsearch cluster as that way single node becomes bottleneck and if that nodes goes down you will not be able to connect to Elasticsearch cluster.
Best is to create a load balancer on top of all your Elasticsearch nodes and connect to your load balancer that will forward request to underlying Elasticsearch nodes.
If you can't create load balancer, instead of single node you can give all nodes ip in your Elasticsearch connection setting to avoid the problem described earlier and also very common as well.
You can create a Elasticsearch client by passing multiple Elasticsearch nodes in the client builder.
Upvotes: 2