# Custom Request Handler

**URL:** <https://discuss.elastic.co/t/custom-request-handler/6605>\
**Category:** Elasticsearch\
**Created:** [February 6, 2012, 3:55pm UTC](https://discuss.elastic.co/t/custom-request-handler/6605 "2012-02-06T15:55:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene\_Strokin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eugene_strokin/32/1238_2.png) [@Eugene\_Strokin](https://discuss.elastic.co/u/Eugene_Strokin)\
**Post date:** [February 6, 2012, 3:55pm UTC](https://discuss.elastic.co/t/custom-request-handler/6605/1 "2012-02-06T15:55:15Z")

</div>

Hello, very often I have a case when I need to make 2 calls to ES for  
a single search, one to get ID's of the documents which I realy need,  
and the second call to actually get those documents.  
The queries are fast, so I don't mind to make 2 calls, but I'm  
thinking about HTTP overhead.  
In Solr, I had Custom Request Handler for such cases. I was getting a  
request on Solr side, ran first query, and right from the Request  
Handler ran the second query right off, without sending response of  
the first request back. And the result of the second query was the  
actual response to the client.  
I wander if this is possible to do on ES? And if it is, could you  
point me to some documentation and/or example of how to do this?  
Also, any suggestion about the subject is appreciated.  
Thank you,  
Eugene S.

---

<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:** [February 7, 2012, 10:08am UTC](https://discuss.elastic.co/t/custom-request-handler/6605/2 "2012-02-07T10:08:05Z")

</div>

If you want to expose a new HTTP / REST endpoint, you can write a plugin that registers a custom REST endpoint, and use the Client API to issue the relevant requests and return a response. If its on the Java API level, you can create your own API extension (much nicer in upcoming 0.19).

On Monday, February 6, 2012 at 5:55 PM, Eugene Strokin wrote:

> Hello, very often I have a case when I need to make 2 calls to ES for  
> a single search, one to get ID's of the documents which I realy need,  
> and the second call to actually get those documents.  
> The queries are fast, so I don't mind to make 2 calls, but I'm  
> thinking about HTTP overhead.  
> In Solr, I had Custom Request Handler for such cases. I was getting a  
> request on Solr side, ran first query, and right from the Request  
> Handler ran the second query right off, without sending response of  
> the first request back. And the result of the second query was the  
> actual response to the client.  
> I wander if this is possible to do on ES? And if it is, could you  
> point me to some documentation and/or example of how to do this?  
> Also, any suggestion about the subject is appreciated.  
> Thank you,  
> Eugene S.

---

<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:40am UTC](https://discuss.elastic.co/t/custom-request-handler/6605/3 "2017-07-06T03:40:21Z")

</div>


