我想通过ES客户端查询crateDB。但是失败
我在es.api.enabled: true
中设置了 crate.yml
,并使用ES java-rest-high-level-client通过端口4200
连接crateDB,但我没有得到任何回应
public class crateAPI {
public static void main(String[] args) throws Exception{
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
new HttpHost("localhost", 4200, "http")));
SearchRequest searchRequest =new SearchRequest();
SearchSourceBuilder searchSourceBuilder =new SearchSourceBuilder();
searchSourceBuilder.query
(QueryBuilders.termQuery("test.news.content","test"));
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = client.search(searchRequest);
for(SearchHit hit : searchResponse.getHits().getHits()){
System.out.println(hit.getSourceAsString());
}
client.close();
}
}
答案 0 :(得分:0)
您可能不应该(很快就会被弃用),如其官方文档here
所建议的那样但是,如果您必须同时这样做,则Crate会像这样响应标准的ES URL搜索
http://your-server:4200/*your-index-name*/_search?q=your-field:your-search-value