正在形成SearchRequest并通过使用ElasticSearch RestHighLevelClient
试图从ElasticSearch中获取文档。但是,尽管ES中的搜索文档出现以下错误。
请在下面找到堆栈跟踪:
`18-Sep-2018 06:35:55.819 SEVERE [Thread-10] com.demo.searchengine.dao.DocumentSearch.getDocumentByName listener timeout after waiting for [30000] ms
java.io.IOException: listener timeout after waiting for [30000] ms
at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:663)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:222)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:194)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:443)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:429)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:368)
at com.demo.searchengine.dao.DocumentSearch.getDocumentByName(DocumentSearch.java:76)
at com.demo.searchengineservice.mqservice.Service.searchByDocuments(Service.java:43)
at com.demo.searchengineservice.mqservice.Consumer.consume(Consumer.java:27)
at com.demo.utils.Consumer$1$1.run(Consumer.java:89)
at java.lang.Thread.run(Unknown Source)`
请在下面找到我的代码:
public class SearchEngineClient {
private static PropertiesFile propertiesFile = PropertiesFile.getInstance();
private final static String elasticHost =propertiesFile.extractPropertiesFile().getProperty("ELASTIC_HOST");
private static RestHighLevelClient instance = new RestHighLevelClient(RestClient.builder(
new HttpHost(elasticHost, 9200, "http"),
new HttpHost(elasticHost, 9201, "http")));
public static RestHighLevelClient getInstance() {
return instance;
}
}
我使用下面的客户端实例从ES获得响应。
searchResponse = SearchEngineClient.getInstance().search(contentSearchRequest);
答案 0 :(得分:0)
似乎无法从外部访问您的Elasticsearch服务器问题。默认情况下,ES服务器将仅绑定到localhost,这意味着无法从外部访问它。
因此,在您的远程ES服务器上,您应该找到elasticsearch.yml配置文件。在此文件中,将network.host更改为您的IP地址或0.0.0.0,以在所有接口上进行侦听。更改之后,您需要重新启动ES。