I am trying to search the data in ES using RestHighLevelClient and referring the documentation available at (https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-search.html) but getting a compilation error "RequestOptions cannot be resolved to a variable" at line "client.search(searchRequest, RequestOptions.DEFAULT);"
Could you please let me know the right way to search the data using RestHighLevelClient.
ES version: 6.3.2
Code:
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(new HttpHost("localhost", 9200, "http"))
.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
public RequestConfig.Builder customizeRequestConfig(RequestConfig.Builder requestConfigBuilder) {
return requestConfigBuilder.setConnectTimeout(5000)
.setSocketTimeout(100000);
}
})
.setMaxRetryTimeoutMillis(100000)
);
SearchRequest searchRequest = new SearchRequest("");
searchRequest.types("doc");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchAllQuery());
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);