Skip to content

Commit f117ab3

Browse files
committed
transportClient requires that the clusterName be specified
1 parent 38f9749 commit f117ab3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

elasticsearch-mapping/src/main/java/org/elasticsearch/mapping/ElasticSearchClient.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import org.elasticsearch.client.transport.TransportClient;
1212
import org.elasticsearch.common.logging.ESLogger;
1313
import org.elasticsearch.common.logging.Loggers;
14+
import org.elasticsearch.common.settings.ImmutableSettings;
15+
import org.elasticsearch.common.settings.Settings;
1416
import org.elasticsearch.common.transport.InetSocketTransportAddress;
1517
import org.elasticsearch.common.unit.TimeValue;
1618
import org.elasticsearch.node.Node;
@@ -42,7 +44,10 @@ public class ElasticSearchClient {
4244
public void initialize() {
4345
if (this.isClient && this.isTransportClient) {
4446
// when these both option are set, we use a transport client
45-
TransportClient transportClient = new TransportClient();
47+
Settings settings = ImmutableSettings.settingsBuilder()
48+
.put("cluster.name", this.clusterName)
49+
.build();
50+
TransportClient transportClient = new TransportClient(settings);
4651
for (InetSocketTransportAddress add : adresses) {
4752
transportClient.addTransportAddress(add);
4853
}

0 commit comments

Comments
 (0)