ElasticSearchv1.7.5 - How to pass ES boolQuery (in json string format) using highlevel rest client


I'm using ElasticSearch v1.7.5 (we cant upgrade to latest version due to other restrictions).

To call ES Search APIs I'm using highLevel Rest client (elasticsearch-rest-high-level-clientv5.6.0).

I need to pass the below request query to client.search() method.
Can you let us know how to pass a query (in string format) in SearchSourceBuilder.query() method?

Request payload:


Client Code:

RestClient restClient = RestClient.builder(new HttpHost(esHost, Integer.valueOf(esPort)))
RestHighLevelClient client = new RestHighLevelClient(restClient);
SearchRequest searchRequest = new SearchRequest("INDEX-NAME");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();

searchSourceBuilder.query( ??? );
SearchResponse searchResponse = client.search(searchRequest);

Thanks in advance for your help.


(Christian Dahlqvist) #2

This is as far as I know not compatible with Elasticsearch 1.7, so is unlikely to work. If you want to use the REST protocol from Java you may need to find an older client library that has support for version 1.7.

JEST might be an option, although I have never used it myself.

(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.