Ciao Sto cercando di connettere il mio ElasticSearch Client al mio localhost e provare a ottenere gli indici da lì.ElasticSearch giving ReceiveTimeoutTransportException
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;
import org.elasticsearch.client.transport.*;
import org.elasticsearch.common.transport.*;
import java.io.IOException;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
public class ESClient
{
public static void search()throws IOException
{
Node node;
node = nodeBuilder().clusterName("elasticsearch").node();
Client client;
client= new TransportClient()
.addTransportAddress(new InetSocketTransportAddress("localhost", 9200));
GetResponse response;
response= client.prepareGet("twitter", "tweet", "1").execute() .actionGet();
System.out.println(response.toString());
}
public static void main(String args[])throws IOException
{
search();
}
}
Ho creato gli indici utilizzando il terminale.
ricciolo -XPUT 'http://localhost:9200/twitter/' ricciolo -XPUT 'http://localhost:9200/twitter/_mapping/tweet' -d '{
"Tweet": { "proprietà": {
"messaggio": { "type": "stringa" , "store": true}}
}} '
Quando sto eseguendo esso, il seguente errore viene generato,
NFO: [Blackheath] non è riuscito a ottenere informazioni nodo per [# trasporto # -1] [BLRMCB-C02L56J4DR53.local] [inet [localhost/127.0.0.1: 9200]], sezionamento ... org. elasticsearch.transport.ReceiveTimeoutTransportException: [] [inet [localhost/127.0.0.1: 9200]] [cluster: monitor/nodi/informazioni] request_id [0] scaduto dopo [5002ms] a org.elasticsearch.transport.TransportService $ TimeoutHandler.run (TransportService.java:366) a java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142) a java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:617) a ja va.lang.Thread.run (Thread.java:745)
Exception in thread "main" org.elasticsearch.client.transport.NoNodeAvailableException: Nessuno dei i nodi configurati sono disponibili: [] a org. elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable (TransportClientNodesService.java:278) a org.elasticsearch.client.transport.TransportClientNodesService.execute (TransportClientNodesService.java:197) a org.elasticsearch.client.transport.support. InternalTransportClient.execute (InternalTransportClient.java:106) a org.elasticsearch.client.support.AbstractClient.get (AbstractC lient.java:193) a org.elasticsearch.client.transport.TransportClient.get (TransportClient.java:384) a org.elasticsearch.action.get.GetRequestBuilder.doExecute (GetRequestBuilder.java:201) a org.elasticsearch.action.ActionRequestBuilder.execute (ActionRequestBuilder.java:91) a org.elasticsearch.action.ActionRequestBuilder.execute (ActionRequestBuilder.java:65) a .... ESClient.search (ESClient.java: 30) a .... ESClient.main (ESClient.java:36) a sun.reflect.NativeMethodAccessorImpl.invoke0 (metodo natale) a sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62).210 a sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) a java.lang.reflect.Method.invoke (Method.java:497) a com.intellij.rt.execution.application.AppMain.main (AppMain.java: 140)
Qual è il problema, qualcuno può dirmelo?