Mufaddal Kamdar
Mufaddal Kamdar

Reputation: 249

Getting 'No Node Available Exception' while using TrasnsportClient of ElasticSearch

I am pretty new to Elastic Search. I have following things in my code OR looking for solution to 'No Node Available Exception' problem in the following scenario.

    1) We have ES running on System with 1 Node and 1 Cluster.
    2) We have 4 indexes on ES. (Each index has different type of data, Example: Customer Preference / Customer Address / Customer Interests / Customer Basic Details)
    3) We have WebApplication (as webservice) running on Tomcat. 4) We are calling webservice method as Controller's. -This will receive request from consumers in the form JSON data.
    5) Based on that data(Example: If consumers asks for Customer Preference for given customer Id then we go to 'Customer Preferences' index) we will go to service(using Spring) layers.
    6) In each of the service layer we get TransportClient instance in SingleTon object and wait for its response and return the result to Controller.

In a Scenario if consumer asks for all 4 types of data for a Customer, and if we ask first for preference, address, interests and basic details in sequence. It works well. But this adds to performance. So we want these things to process and get data parallel.

So we used Spring Task Executors to do this parallel. In that case we get data from one index and others will get 'No Node Available Exception'. Its pretty random to on say on which data we get this problem.

Pleas help me here.

Thanks in advance!....

Upvotes: 2

Views: 853

Answers (1)

Siva Kumar
Siva Kumar

Reputation: 560

I had a similar issue, when trying to write data into a same ES node from multiple web applications. I fixed it by creating separate nodes for each.

I suggest you to try these settings of ES

client.transport.sniff=true
sniffOnConnectionFault=true

Also you can get the data from 4 indexes in a single query. For Customer Preference / Customer Address / Customer Interests / Customer Basic Details.

Example code:

SearchRequestBuilder srb = client
.prepareSearch("preference_index", "address_index", "interests_index", "details_index")
.setTypes("preference_doc", "address_doc", "interests_doc", "details_doc")
.setSearchType(SearchType.DEFAULT);

QueryBuilder boolBuilder = QueryBuilders.boolQuery().should(
QueryBuilders.matchQuery("id_customer", "14"));

SearchResponse response = srb.setSize(4).execute().actionGet();
SearchHit[] docs = response.getHits().getHits();

Upvotes: 1

Related Questions