我有一個春天啓動應用程序,我想用彈性搜索2.2.0獨立的(不嵌入式服務器)中,我想使用Spring數據彈性搜索數據春季彈性搜索,那麼什麼是Spring Data支持彈性搜索的版本,以及如何配置它以連接到在localhost中運行的elasticsearch實例:9200?在Spring啓動應用程序
其實,我嘗試添加該選項到我的application.properties文件:
spring.data.elasticsearch.repositories.enabled=true
spring.data.elasticsearch.cluster-nodes=localhost:9200
後來,我創建了這個配置類:
@Configuration
public class ElasticConfig {
@Bean
public ElasticsearchOperations elasticsearchTemplate() {
return new ElasticsearchTemplate(client());
}
@Bean
public Client client() {
TransportClient client = new TransportClient();
TransportAddress address = new InetSocketTransportAddress(
"localhost",9200);
client.addTransportAddress(address);
return client;
}
}
我得到這個堆棧跟蹤:
2016年4月28日00:03:52.246 INFO 25613 --- [restartedMain] org.elasticsearch.plugins:[阿德沃夫]加載[],網站 [] 2016-04-28 00:04:01.356信息25613 --- [restartedMain] org.elasticsearch.client.transport:[Aardwolf]未能獲得 節點信息爲 [#transport #-1] [fathi-HP-Pavilion-g6-Notebook-PC] [inet [localhost/127.0.0.1:9200]],斷開...
org.elasticsearch.transport.ReceiveTimeoutTransportException: [] [ INET [本地主機/ 127.0.0.1:9200] [簇:顯示器/節點/信息] REQUEST_ID [0]超時[5001ms]在 org.elasticsearch.transport.TransportService $ TimeoutHandler.run後(TransportService.java:529 ) 〜[elasticsearch-1.5.2.jar:NA]在 java.util.concurrent.ThreadPoolExecutor.ru nWorker(ThreadPoolExecutor.java:1142) 〜[na:1.8.0_77] at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 〜[na:1.8.0_77] at java.lang .Thread.run(Thread.java:745) 〜[NA:1.8.0_77]
2016年4月28日00:04:01.512 ERROR 25613 --- [restartedMain] .dersAbstractElasticsearchRepository:未能加載 elasticsearch節點: org.elasticsearch.client.transport.NoNodeAvailableException:的 沒有所配置的節點是可用的:[]
這只是一個客戶端:
,如果您需要了解更多信息,請看看這個帖子。請檢查您的elasticsearch服務器狀態。 –
@Gemini Keith:elasticsearch啓動並運行:http:// localhost:9200/{ 「name」:「Hildegarde」, 「cluster_name」:「elasticsearch」, 「version」:{ 「number」:「 2.2.0" , 「build_hash」: 「8ff36d139e16f8720f2947ef62c8167a888992fe」, 「build_timestamp」: 「2016-01-27T13:32:39Z」, 「build_snapshot」:假, 「lucene_version」: 「5.4.1」 } , 「tagline」:「你知道,搜索」 } – jemlifathi
看到這個答案:http://stackoverflow.com/a/36858819/4604579。 Spring Data尚未準備好ES 2.x – Val