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

**URL:** <https://discuss.elastic.co/t/elasticsearchv1-7-5-how-to-pass-es-boolquery-in-json-string-format-using-highlevel-rest-client/140097>\
**Category:** Elasticsearch\
**Created:** [July 16, 2018, 7:44am UTC](https://discuss.elastic.co/t/elasticsearchv1-7-5-how-to-pass-es-boolquery-in-json-string-format-using-highlevel-rest-client/140097 "2018-07-16T07:44:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![suri](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@suri](https://discuss.elastic.co/u/suri)\
**Post date:** [July 16, 2018, 7:44am UTC](https://discuss.elastic.co/t/elasticsearchv1-7-5-how-to-pass-es-boolquery-in-json-string-format-using-highlevel-rest-client/140097/1 "2018-07-16T07:44:06Z")

</div>

Hi,  
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:**

> {"query":{"filtered":{"filter":{"bool":{"must":[{"term":{"siteId":"1234"}},{"terms":{"studentId":["ram"]}},{"range":{"timestamp":{"from":"1501128000000","to":"1523469369861"}}}]}}}},"size":10000,"from":0,"sort":[{"timestamp":{"order":"asc"}}]}

**Client Code:**

> RestClient restClient = RestClient.builder(new HttpHost(esHost, Integer.valueOf(esPort)))  
> .setDefaultHeaders(headers).build();  
> RestHighLevelClient client = new RestHighLevelClient(restClient);  
> SearchRequest searchRequest = new SearchRequest("INDEX-NAME");  
> SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
> 
> **_searchSourceBuilder.query( ??? );_**  
> searchSourceBuilder.fetchSource(true);  
> searchRequest.source(searchSourceBuilder);  
> SearchResponse searchResponse = client.search(searchRequest);

Thanks in advance for your help.

Regards  
Suri

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 16, 2018, 7:50am UTC](https://discuss.elastic.co/t/elasticsearchv1-7-5-how-to-pass-es-boolquery-in-json-string-format-using-highlevel-rest-client/140097/2 "2018-07-16T07:50:05Z")

</div>

> [@suri](#):
>
> To call ES Search APIs I'm using highLevel Rest client (elasticsearch-rest-high-level-clientv5.6.0).

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](https://github.com/searchbox-io/Jest/tree/master/jest) might be an option, although I have never used it myself.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 13, 2018, 7:50am UTC](https://discuss.elastic.co/t/elasticsearchv1-7-5-how-to-pass-es-boolquery-in-json-string-format-using-highlevel-rest-client/140097/3 "2018-08-13T07:50:17Z")

</div>

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