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 <[email protected]> wrote:

> Change port number to 9300
>
> --
> *David Pilato* | *Technical Advocate* | *Elasticsearch.com*
> @dadoonet <https://twitter.com/dadoonet> | 
> @elasticsearchfr<https://twitter.com/elasticsearchfr>
>
>
> Le 19 février 2014 à 19:52:53, praveen kotla ([email protected]) 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 [email protected].
>
> To view this discussion on the web visit
> 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.
>
>  --
> 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.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> 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.
>



-- 
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 [email protected].
To view this discussion on the web visit 
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.

Reply via email to