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