2016-11-04 2 views
1

私はElastic Search Java Api [5.0]の新機能です。私はelasticsearch-5.0.0を使用しています。 私はSpringブートでJavaアプリケーション(Maven)を作成しようとしています。実行アプリケーションの後、それはorg.elasticsearch.transport.NodeDisconnectedExceptionの取得:[] [inet [localhost/127.0.0.1:9300]] [クラスタ/ノード/情報] disconnected

2016-11-04 23:32:19.339 INFO 8280 --- [][generic][T#2]]  org.elasticsearch.client.transport  : [X-Ray] failed to get node info for [#transport#-1][DESKTOP-8SIPHSN][inet[localhost/127.0.0.1:9300]], disconnecting... 
org.elasticsearch.transport.NodeDisconnectedException: [][inet[localhost/127.0.0.1:9300]][cluster:monitor/nodes/info] disconnected 
を示し は

私の設定ファイルは

@Configuration 
public class ElasticsearchConfiguration { 

    @Bean 
    public Client client() { 

     TransportClient client = new TransportClient(); 
     TransportAddress address = new InetSocketTransportAddress("localhost",9300); 
     client.addTransportAddress(address);   
     return client; 
    } 

} 

であり、私はデフォルトのクラスタ "elasticsearch" を使用しています。私は原因を適切に検出して問題を解決するために助けが必要です。

答えて

5

5.0ドキュメントに記載PreBuiltTransportClient使用してみてください:

The client must have the same major version (e.g. 2.x, or 5.x) as the nodes in the cluster. Clients may connect to clusters which have a different minor version (e.g. 2.3.x) but it is possible that new functionality may not be supported. Ideally, the client should have the same version as the cluster.

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY) 
     .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300)); 

https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html

はまたESバージョン2.x用TransportClientが5.xのと互換性がないことに注意してください

https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/client.html

更新

接続テストとして、以下の簡単なプログラムを実行してみてください:それはstdoutに印刷する必要があり

import org.elasticsearch.client.transport.TransportClient; 
import org.elasticsearch.common.settings.Settings; 
import org.elasticsearch.common.transport.InetSocketTransportAddress; 
import org.elasticsearch.transport.client.PreBuiltTransportClient; 

import java.net.InetAddress; 
import java.net.UnknownHostException; 

public class App { 
    public static void main(String[] args) throws UnknownHostException { 
     // The following settings aren't strictly necessary, because the default cluster name is "elasticsearch". 
     Settings settings = Settings.builder().put("cluster.name", "elasticsearch").build(); 
     TransportClient client = new PreBuiltTransportClient(settings); 
     client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300)); 
     System.out.println(client.connectedNodes()); 
    } 
} 

を次の行のようなもの:

[{luhcORJ}{luhcORJOSzSLPBeXocDsuQ}{mkTJpwIAQGuNYTHfRLqUIw}{127.0.0.1}{127.0.0.1:9300}]

+0

私は を使用しています' org.elasticsearch.client 輸送 5.0.0 ' –

+0

私はこのコード 'のtransportClientクライアント=新しいPreBuiltTransportClient(Settings.EMPTY) .addTransportAddress(新しいInetSocketTransportAddress(InetAddress.getByName( "localhost" を)、9300しようとしています)); ' しかし、エラーが表示されるSettings.EMPTY –

+0

クラスタの名前を変更しましたか? 'elasticsearch'以外のものなら、' TransportClient'設定の 'cluster.name'プロパティで指定する必要があります。 – ck1

関連する問題