# Building queries by Java API but calling ELS by Rest

**URL:** <https://discuss.elastic.co/t/building-queries-by-java-api-but-calling-els-by-rest/112589>\
**Category:** Elasticsearch\
**Created:** [December 20, 2017, 8:50am UTC](https://discuss.elastic.co/t/building-queries-by-java-api-but-calling-els-by-rest/112589 "2017-12-20T08:50:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hym](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hym/32/22399_2.png) [@hym](https://discuss.elastic.co/u/hym)\
**Post date:** [December 20, 2017, 8:50am UTC](https://discuss.elastic.co/t/building-queries-by-java-api-but-calling-els-by-rest/112589/1 "2017-12-20T08:50:45Z")

</div>

Hi,

I've found Java API for building queries very convenient in the java application, on the other hand, I want to use Rest Client to call Elastic cluster.  
Is this a right approach to use Java API to build my queries and get the query string and call with Rest? Or is that possible?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 20, 2017, 9:05am UTC](https://discuss.elastic.co/t/building-queries-by-java-api-but-calling-els-by-rest/112589/2 "2017-12-20T09:05:27Z")

</div>

Are you looking for [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high.html) ?

---

<div class="post-metadata">

**Author:** ![hym](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hym/32/22399_2.png) [@hym](https://discuss.elastic.co/u/hym)\
**Post date:** [December 20, 2017, 10:02am UTC](https://discuss.elastic.co/t/building-queries-by-java-api-but-calling-els-by-rest/112589/3 "2017-12-20T10:02:16Z")

</div>

Thanks, this is right API I am looking for but actually, I had seen this one.  
My process is like this:  
I first create my queries by Elastic test framework and by end of the day I transfer those queries to the real application. Unfortunately, I could not get this high-level rest client from Test-framework.  
I want to get this rest client from test framework and code against it and by the end of the day simply copy my code from test classes to the real application without any change.

[Test Framework says you can access the TransportClient or NodeClient](https://www.elastic.co/guide/en/elasticsearch/reference/current/integration-tests.html#accessing-clients)  
I was wondering if there is any way to pass queries built by High-level java rest (SearchSourceBuilder and SearchRequest) to these clients in test framework?

Thanks again

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 20, 2017, 10:21am UTC](https://discuss.elastic.co/t/building-queries-by-java-api-but-calling-els-by-rest/112589/4 "2017-12-20T10:21:40Z")

</div>

Ha. So here is what I did (workaround described in the issue):

> <https://github.com/elastic/elasticsearch/issues/27304>

I hope this helps

---

<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:** [January 17, 2018, 10:22am UTC](https://discuss.elastic.co/t/building-queries-by-java-api-but-calling-els-by-rest/112589/5 "2018-01-17T10:22:12Z")

</div>

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