I wanna query crateDB through ES client.But failed
I set the es.api.enabled: true
in the crate.yml
and I used the ES java-rest-high-level-client to connect crateDB via port 4200
, but I cannot get any response
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();
}
}
You probably shouldn't (and soon be deprecated) as advised in their official documentation here
But if you have to in the mean time, Crate will respond to a standard ES URL search like so
http://your-server:4200/*your-index-name*/_search?q=your-field:your-search-value