# Need help in connecting to remote server to search the logs

**URL:** <https://discuss.elastic.co/t/need-help-in-connecting-to-remote-server-to-search-the-logs/15906>\
**Category:** Elasticsearch\
**Created:** [February 19, 2014, 6:52pm UTC](https://discuss.elastic.co/t/need-help-in-connecting-to-remote-server-to-search-the-logs/15906 "2014-02-19T18:52:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![praveen\_kotla](https://avatars.discourse-cdn.com/v4/letter/p/77aa72/32.png) [@praveen\_kotla](https://discuss.elastic.co/u/praveen_kotla)\
**Post date:** [February 19, 2014, 6:52pm UTC](https://discuss.elastic.co/t/need-help-in-connecting-to-remote-server-to-search-the-logs/15906/1 "2014-02-19T18:52:49Z")

</div>

Hi All,  
I am new to Elastic Search.  
I am trying to connect to the remote server and search content in one of  
the nodes present there.  
I have kept some dummy cluster name and node names. We actually have  
different. i tried different settings but nothing working.  
We have 1 cluster and 12 nodes.  
We want to search under all nodes.

PS Can somebody share the sample code which connects to remote server and  
perform search

Exception Occured:  
org.elasticsearch.client.transport.NoNodeAvailableException: No node  
available  
at  
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:219)  
at  
org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)  
at  
org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:214)  
at  
org.elasticsearch.client.transport.TransportClient.search(TransportClient.java:414)  
at  
org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:944)  
at  
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)  
at  
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)  
at main.java.com.kodcu.main.Test.main(Test.java:180)

Below is the sample code

import java.util.Map;

import org.elasticsearch.action.search.SearchRequestBuilder;

import org.elasticsearch.action.search.SearchResponse;

import org.elasticsearch.action.search.SearchType;

import org.elasticsearch.client.transport.TransportClient;

import org.elasticsearch.common.settings.ImmutableSettings;

import org.elasticsearch.common.settings.Settings;

import org.elasticsearch.common.transport.InetSocketTransportAddress;

import org.elasticsearch.index.query.QueryBuilder;

import org.elasticsearch.index.query.QueryBuilders;

import org.elasticsearch.search.SearchHit;

public class Test {

```
            public static void main(String[] args) {

                            try {

                                         Settings settings = 

```

ImmutableSettings.settingsBuilder().put("cluster.name",  
"TEST\_CLUSTER").put("network.server", true).put("node.name",  
"TEST").build();

```
                                            TransportClient client = 

```

new TransportClient(settings);

```
                                            client = 

```

client.addTransportAddress(new  
InetSocketTransportAddress("RemoteServerName", 9200));

System.out.println(client);

//  
SearchResponse response = client.prepareSearch().execute().actionGet();

QueryBuilder qb = QueryBuilders.matchQuery("query", "app\_name=BS AND  
4335445c090998311e381b3bf9711fa8dc3");

SearchRequestBuilder builder =  
client.prepareSearch("logstash-2014.02.19").setTypes("application")

.setSearchType(SearchType.QUERY\_AND\_FETCH)

```
                .setQuery(qb)

```

.setExplain(true);

SearchResponse response = builder.execute().actionGet();

```
                                                            SearchHit[] 

```

results = response.getHits().getHits();

System.out.println("Current results: " + results.length);

```
                                                            for 

```

(SearchHit hit : results) {

System.out.println("------------------------------");

Map\<String, Object\> result = hit.getSource();

System.out.println(result);

```
                                                            }

```

client.close();

```
                            } catch (Exception e) {

                                            e.printStackTrace();

                            }

            }

```

}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/deff81f9-f66d-4da6-a7b2-be3d465f24de%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/deff81f9-f66d-4da6-a7b2-be3d465f24de%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 19, 2014, 9:30pm UTC](https://discuss.elastic.co/t/need-help-in-connecting-to-remote-server-to-search-the-logs/15906/2 "2014-02-19T21:30:49Z")

</div>

Change port number to 9300

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 19 février 2014 à 19:52:53, praveen kotla ([kotlapraveen@gmail.com](mailto:kotlapraveen@gmail.com)) a écrit:

Hi All,  
I am new to Elastic Search.  
I am trying to connect to the remote server and search content in one of the nodes present there.  
I have kept some dummy cluster name and node names. We actually have different. i tried different settings but nothing working.  
We have 1 cluster and 12 nodes.  
We want to search under all nodes.

PS Can somebody share the sample code which connects to remote server and perform search

Exception Occured:  
org.elasticsearch.client.transport.NoNodeAvailableException: No node available  
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:219)  
at org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)  
at org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:214)  
at org.elasticsearch.client.transport.TransportClient.search(TransportClient.java:414)  
at org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:944)  
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)  
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)  
at main.java.com.kodcu.main.Test.main(Test.java:180)

Below is the sample code

import java.util.Map;

import org.elasticsearch.action.search.SearchRequestBuilder;

import org.elasticsearch.action.search.SearchResponse;

import org.elasticsearch.action.search.SearchType;

import org.elasticsearch.client.transport.TransportClient;

import org.elasticsearch.common.settings.ImmutableSettings;

import org.elasticsearch.common.settings.Settings;

import org.elasticsearch.common.transport.InetSocketTransportAddress;

import org.elasticsearch.index.query.QueryBuilder;

import org.elasticsearch.index.query.QueryBuilders;

import org.elasticsearch.search.SearchHit;

public class Test {

```
            public static void main(String[] args) {

                            try {

                                         Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "TEST_CLUSTER").put("network.server", true).put("node.name", "TEST").build();

                                            TransportClient client = new TransportClient(settings);

                                            client = client.addTransportAddress(new InetSocketTransportAddress("RemoteServerName", 9200));

                                                        

                                                            System.out.println(client);

```

// SearchResponse response = client.prepareSearch().execute().actionGet();

```
                                                            QueryBuilder qb = QueryBuilders.matchQuery("query", "app_name=BS AND 4335445c090998311e381b3bf9711fa8dc3");

                                                            SearchRequestBuilder builder = client.prepareSearch("logstash-2014.02.19").setTypes("application")

                                                                                            .setSearchType(SearchType.QUERY_AND_FETCH)

                                                                                            .setQuery(qb)

                                                                                            .setExplain(true);

                                                            SearchResponse response = builder.execute().actionGet();

                                                            SearchHit[] results = response.getHits().getHits();

                                                            System.out.println("Current results: " + results.length);

                                                            for (SearchHit hit : results) {

                                                                            System.out.println("------------------------------");

                                                                            Map<String, Object> result = hit.getSource();

                                                                            System.out.println(result);

                                                            }

                                                            client.close();

                            } catch (Exception e) {

                                            e.printStackTrace();

                            }

            }

```

}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/deff81f9-f66d-4da6-a7b2-be3d465f24de%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/deff81f9-f66d-4da6-a7b2-be3d465f24de%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.53052289.519b500d.3861%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.53052289.519b500d.3861%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![praveen\_kotla](https://avatars.discourse-cdn.com/v4/letter/p/77aa72/32.png) [@praveen\_kotla](https://discuss.elastic.co/u/praveen_kotla)\
**Post date:** [February 19, 2014, 9:40pm UTC](https://discuss.elastic.co/t/need-help-in-connecting-to-remote-server-to-search-the-logs/15906/3 "2014-02-19T21:40:38Z")

</div>

Thanks David it works fine  
The url to connect to the server has port 9200. My bad

Thanks,  
Praveen K Kotla

On Wed, Feb 19, 2014 at 3:30 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Change port number to 9300
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 19 février 2014 à 19:52:53, praveen kotla ([kotlapraveen@gmail.com](mailto:kotlapraveen@gmail.com)) a  
> écrit:
> 
> Hi All,  
> I am new to Elastic Search.  
> I am trying to connect to the remote server and search content in one of  
> the nodes present there.  
> I have kept some dummy cluster name and node names. We actually have  
> different. i tried different settings but nothing working.  
> We have 1 cluster and 12 nodes.  
> We want to search under all nodes.
> 
> PS Can somebody share the sample code which connects to remote server and  
> perform search
> 
> Exception Occured:  
> org.elasticsearch.client.transport.NoNodeAvailableException: No node  
> available  
> at  
> org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:219)  
> at  
> org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)  
> at  
> org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:214)  
> at  
> org.elasticsearch.client.transport.TransportClient.search(TransportClient.java:414)  
> at  
> org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:944)  
> at  
> org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)  
> at  
> org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)  
> at main.java.com.kodcu.main.Test.main(Test.java:180)
> 
> Below is the sample code
> 
> import java.util.Map;
> 
> import org.elasticsearch.action.search.SearchRequestBuilder;
> 
> import org.elasticsearch.action.search.SearchResponse;
> 
> import org.elasticsearch.action.search.SearchType;
> 
> import org.elasticsearch.client.transport.TransportClient;
> 
> import org.elasticsearch.common.settings.ImmutableSettings;
> 
> import org.elasticsearch.common.settings.Settings;
> 
> import org.elasticsearch.common.transport.InetSocketTransportAddress;
> 
> import org.elasticsearch.index.query.QueryBuilder;
> 
> import org.elasticsearch.index.query.QueryBuilders;
> 
> import org.elasticsearch.search.SearchHit;
> 
> public class Test {
> 
> ```
> public static void main(String[] args) {
> 
> try {
> 
> Settings settings =
> 
> ```
> 
> ImmutableSettings.settingsBuilder().put("cluster.name",  
> "TEST\_CLUSTER").put("network.server", true).put("node.name",  
> "TEST").build();
> 
> ```
> TransportClient client =
> 
> ```
> 
> new TransportClient(settings);
> 
> ```
> client =
> 
> ```
> 
> client.addTransportAddress(new  
> InetSocketTransportAddress("RemoteServerName", 9200));
> 
> System.out.println(client);
> 
> //  
> SearchResponse response = client.prepareSearch().execute().actionGet();
> 
> QueryBuilder qb = QueryBuilders.matchQuery("query", "app\_name=BS AND  
> 4335445c090998311e381b3bf9711fa8dc3");
> 
> SearchRequestBuilder builder =  
> client.prepareSearch("logstash-2014.02.19").setTypes("application")
> 
> .setSearchType(SearchType.QUERY\_AND\_FETCH)
> 
> ```
> .setQuery(qb)
> 
> ```
> 
> .setExplain(true);
> 
> SearchResponse response = builder.execute().actionGet();
> 
> SearchHit results = response.getHits().getHits();
> 
> System.out.println("Current results: " + results.length);
> 
> ```
> for
> 
> ```
> 
> (SearchHit hit : results) {
> 
> System.out.println("------------------------------");
> 
> Map\<String, Object\> result = hit.getSource();
> 
> System.out.println(result);
> 
> ```
> }
> 
> ```
> 
> client.close();
> 
> ```
> } catch (Exception e) {
> 
> e.printStackTrace();
> 
> }
> 
> }
> 
> ```
> 
> ## }
> 
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).
> 
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/deff81f9-f66d-4da6-a7b2-be3d465f24de%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/deff81f9-f66d-4da6-a7b2-be3d465f24de%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/rJaBQlDkcL8/unsubscribe](https://groups.google.com/d/topic/elasticsearch/rJaBQlDkcL8/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/etPan.53052289.519b500d.3861%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.53052289.519b500d.3861%40MacBook-Air-de-David.local)  
> .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Regards,  
Praveen K Kotla

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAH-5PhC03iA5K\_hkaWk%3D30ncBqLD2rOYS-7Omqzg-i4hvCNWqA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAH-5PhC03iA5K_hkaWk%3D30ncBqLD2rOYS-7Omqzg-i4hvCNWqA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 1:48am UTC](https://discuss.elastic.co/t/need-help-in-connecting-to-remote-server-to-search-the-logs/15906/4 "2017-07-06T01:48:59Z")

</div>


