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.

Reply via email to