0

I want to create a connection with elasticsearch in order to exectue a query

this is my exception déc. 28, 2017 10:06:11 AM

org.elasticsearch.plugins.PluginsService <init>
INFOS: [Shockwave] modules [], plugins [], sites []

Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: []]
    at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207)
at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56)
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:64)
at com.intelcom.boot.App.<init>(App.java:59)
at com.intelcom.boot.App.main(App.java:71)

this is my main code

TransportClient client ;
        InetSocketTransportAddress node = new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300);

        Settings settings = Settings.builder().put("cluster.name", "elasticsearch").put("client.transport.sniff", true)
                .build();
            client = TransportClient.builder().settings(settings).build();
        SearchRequestBuilder builder = client.prepareSearch("index")
                .setTypes("index_type")
                .setQuery(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("_all", "Rabat")));

        System.out.println(builder);
        SearchResponse response = builder.get(); //<<<==== error

thanks for helping

2
  • node is never used.... Commented Dec 28, 2017 at 10:53
  • how can I add it ?? (thanks youu sos much ) Commented Dec 28, 2017 at 10:58

1 Answer 1

1

your initialization of es transport client is wrong:

Here is an simple example of initialization:

Settings settings = Settings.builder()
    .put("cluster.name", "myClusterName").build();
TransportClient client = new PreBuiltTransportClient(settings).addTransportAddress(new TransportAddress(InetAddress.getByName("host1"), 9300))
    .addTransportAddress(new TransportAddress(InetAddress.getByName("host2"), 9300));

more refer to link

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.