# How to search in many cluster name?

**URL:** <https://discuss.elastic.co/t/how-to-search-in-many-cluster-name/33611>\
**Category:** Elasticsearch\
**Created:** [November 3, 2015, 8:56am UTC](https://discuss.elastic.co/t/how-to-search-in-many-cluster-name/33611 "2015-11-03T08:56:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NgocPham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ngocpham/32/6242_2.png) [@NgocPham](https://discuss.elastic.co/u/NgocPham)\
**Post date:** [November 3, 2015, 8:56am UTC](https://discuss.elastic.co/t/how-to-search-in-many-cluster-name/33611/1 "2015-11-03T08:56:27Z")

</div>

sorry , im newbie and i have one question.  
Default cluster name is "elasticsearch",i run and get transtport in port :9300 like this:

```
     Settings settings = ImmutableSettings.settingsBuilder().put("client.transport.sniff", true)
        				.put("cluster.name", "elasticsearch").build();
        		transportClient = new TransportClient(settings);
Client client = transportClient.addTransportAddress(new InetSocketTransportAddress("192.168.1.25", 9300))

```

But now i change cluster name is : "elasticsearch1" and i run in port :9302.

```
Settings settings2 = ImmutableSettings.settingsBuilder().put("client.transport.sniff", true)
			.put("cluster.name", "elasticsearch1").build();
	transportClient2 = new TransportClient(settings2);
Client client2 = transportClient2.addTransportAddress(new InetSocketTransportAddress("192.168.1.25", 9302));

```

My question is : how to search in 2 client in one time if i have same index,same type, search \_all field and only different database?

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [November 3, 2015, 11:25am UTC](https://discuss.elastic.co/t/how-to-search-in-many-cluster-name/33611/2 "2015-11-03T11:25:49Z")

</div>

Hi,  
afaik with this setup (two clients, two clusters) you need to run request on each of them independently. There is something called a [Tribe Node](https://www.elastic.co/guide/en/elasticsearch/reference/2.0/modules-tribe.html) which can connect to multiple clusters, but for your particular case this won't help much, it cannot handle indices with the same name in multiple clusters.

---

<div class="post-metadata">

**Author:** ![NgocPham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ngocpham/32/6242_2.png) [@NgocPham](https://discuss.elastic.co/u/NgocPham)\
**Post date:** [November 4, 2015, 10:03am UTC](https://discuss.elastic.co/t/how-to-search-in-many-cluster-name/33611/3 "2015-11-04T10:03:40Z")

</div>

Thanks , i created cluster elasticsearch in port 9200, elasticsearch1 in 9201 and i change cluster name defaul in .yml to :elasticsearch2. After i use terminal

```
bin/elasticsearch --tribe.elasticsearch1.cluster.name elasticsearch1 --tribe.elasticsearch.cluster.name elasticsearch --tribe.elasticsearch.cluster.name elasticsearch 

```

i success creat cluster in port 9202 like you say, i can see index in cluster elasticsearch and elasticsearch1.  
I can check all index exist in curl 'localhost:9202/\_cat/indices?v' .

But i cant search with java , this is code i used

```
Settings settings = ImmutableSettings.settingsBuilder().put("client.transport.sniff", true)
				.put("cluster.name", "elasticsearch2").build();
		transportClient = new TransportClient(settings);

		Client client = transportClient.addTransportAddress(new InetSocketTransportAddress("192.168.1.25", 9301));

```

it only search index in one cluster.  
but if i remove `.put("client.transport.sniff", true)`  
it can search all index in 2 cluster like normal.

I readed in [https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.7/transport-client.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.7/transport-client.html) . It have

- The client allows to sniff the rest of the cluster, and add those  
into its list of machines to use. In this case, note that the IP  
addresses used will be the ones that the other nodes were started  
with (the "publish" address). In order to enable it, set the  
client.transport.sniff to true:

But i cant understand what really happen. Pls explain me 😄

Thanks for your help !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:40pm UTC](https://discuss.elastic.co/t/how-to-search-in-many-cluster-name/33611/4 "2017-07-05T23:40:39Z")

</div>


