# What is the best way to proceed?

**URL:** <https://discuss.elastic.co/t/what-is-the-best-way-to-proceed/5891>\
**Category:** Elasticsearch\
**Created:** [November 16, 2011, 9:09pm UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-proceed/5891 "2011-11-16T21:09:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Garth](https://avatars.discourse-cdn.com/v4/letter/g/ba9def/32.png) [@Garth](https://discuss.elastic.co/u/Garth)\
**Post date:** [November 16, 2011, 9:09pm UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-proceed/5891/1 "2011-11-16T21:09:44Z")

</div>

I would like to intercept the JSON query coming in and rewrite it,  
passing off to ES to execute. Can I do this with a plugin, extend the  
framework, or should I AspectJ particular Java classes of ES to make  
this work.

Thanks,

Garth

---

<div class="post-metadata">

**Author:** ![Nick\_Hoffman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_hoffman/32/1872_2.png) [@Nick\_Hoffman](https://discuss.elastic.co/u/Nick_Hoffman)\
**Post date:** [November 16, 2011, 10:16pm UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-proceed/5891/2 "2011-11-16T22:16:54Z")

</div>

If you're going to modify the query between the client and ES, I recommend  
creating a web service that does this, such that:

- The client queries the web service.
- The web service modifies the query.
- The web service sends the modified query to ES.
- The web service returns the response from ES.

---

<div class="post-metadata">

**Author:** ![Garth](https://avatars.discourse-cdn.com/v4/letter/g/ba9def/32.png) [@Garth](https://discuss.elastic.co/u/Garth)\
**Post date:** [November 16, 2011, 10:20pm UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-proceed/5891/3 "2011-11-16T22:20:24Z")

</div>

Yeah that's the route I really wanted to go. I have been directed to  
not stand up a web service.

On Nov 16, 5:16 pm, Nick Hoffman [n...@deadorange.com](mailto:n...@deadorange.com) wrote:

> If you're going to modify the query between the client and ES, I recommend  
> creating a web service that does this, such that:
> 
> - The client queries the web service.
> - The web service modifies the query.
> - The web service sends the modified query to ES.
> - The web service returns the response from ES.

---

<div class="post-metadata">

**Author:** ![Garth](https://avatars.discourse-cdn.com/v4/letter/g/ba9def/32.png) [@Garth](https://discuss.elastic.co/u/Garth)\
**Post date:** [November 16, 2011, 10:42pm UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-proceed/5891/4 "2011-11-16T22:42:48Z")

</div>

I have written a test client w the JavaAPI. I have not seen an API  
call that would take a JSON query as if I had passed it in with Curl.  
Is there one?

On Nov 16, 5:16 pm, Nick Hoffman [n...@deadorange.com](mailto:n...@deadorange.com) wrote:

> If you're going to modify the query between the client and ES, I recommend  
> creating a web service that does this, such that:
> 
> - The client queries the web service.
> - The web service modifies the query.
> - The web service sends the modified query to ES.
> - The web service returns the response from ES.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 17, 2011, 1:11pm UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-proceed/5891/5 "2011-11-17T13:11:45Z")

</div>

SearchRequestBuilder#setSource allows to pass the actual "body" of the  
request. Regarding munging the query sent, its best to do it outside of  
elasticsearch.

On Thu, Nov 17, 2011 at 12:42 AM, Garth [ghershfield.bah@gmail.com](mailto:ghershfield.bah@gmail.com) wrote:

> I have written a test client w the JavaAPI. I have not seen an API  
> call that would take a JSON query as if I had passed it in with Curl.  
> Is there one?
> 
> On Nov 16, 5:16 pm, Nick Hoffman [n...@deadorange.com](mailto:n...@deadorange.com) wrote:
> 
> > If you're going to modify the query between the client and ES, I  
> > recommend  
> > creating a web service that does this, such that:
> > 
> > - The client queries the web service.
> > - The web service modifies the query.
> > - The web service sends the modified query to ES.
> > - The web service returns the response from ES.

---

<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:** [July 6, 2017, 3:48am UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-proceed/5891/6 "2017-07-06T03:48:19Z")

</div>


