# Search Plugin to intercept search response

**URL:** <https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494>\
**Category:** Elasticsearch\
**Created:** [August 27, 2014, 1:05pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494 "2014-08-27T13:05:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElasticSearch\_Users\_](https://avatars.discourse-cdn.com/v4/letter/e/b4bc9f/32.png) [@ElasticSearch\_Users\_](https://discuss.elastic.co/u/ElasticSearch_Users_)\
**Post date:** [August 27, 2014, 1:05pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/1 "2014-08-27T13:05:59Z")

</div>

Hi,

Is there any action/module that I can extend/register/add so that I can  
intercept the SearchResponse on the server node before the response is sent  
back to the TransportClient on the calling box?

Thanks,  
Sandeep

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [August 27, 2014, 1:08pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/2 "2014-08-27T13:08:47Z")

</div>

Have a look at array-format or csv plugin, they are processing the  
SearchResponse to output it in another format:

[https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)

> **[GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search...](https://github.com/jprante/elasticsearch-csv)**
>
> CSV format for Elasticsearch REST search responses - GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses

Jörg

On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:

> Hi,
> 
> Is there any action/module that I can extend/register/add so that I can  
> intercept the SearchResponse on the server node before the response is sent  
> back to the TransportClient on the calling box?
> 
> Thanks,  
> Sandeep
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Sandeep\_Ramesh\_Khanz](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@Sandeep\_Ramesh\_Khanz](https://discuss.elastic.co/u/Sandeep_Ramesh_Khanz)\
**Post date:** [September 10, 2014, 9:59am UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/3 "2014-09-10T09:59:00Z")

</div>

Hi Jorg,

Thanks for the links. I was checking the sources. There are relevant to my  
functional use case. But I will be using the TransportClient Java API, not  
the REST client.

Can you please tell me how I can find/modify these classes/sources to get  
the appropriate classes for inctercepting the Search Response when invoked  
from a TransportClient?

Thanks,  
Sandeep

On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
[joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:

> Have a look at array-format or csv plugin, they are processing the  
> SearchResponse to output it in another format:
> 
> [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> 
> [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> 
> Jörg
> 
> On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> 
> > Hi,
> > 
> > Is there any action/module that I can extend/register/add so that I can  
> > intercept the SearchResponse on the server node before the response is sent  
> > back to the TransportClient on the calling box?
> > 
> > Thanks,  
> > Sandeep
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 11, 2014, 7:13am UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/4 "2014-09-11T07:13:52Z")

</div>

You can receive the SearchResponse, process the response, and return the  
response with whatever format you want.

Jörg

On Wed, Sep 10, 2014 at 11:59 AM, Sandeep Ramesh Khanzode \<  
[k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com)\> wrote:

> Hi Jorg,
> 
> Thanks for the links. I was checking the sources. There are relevant to my  
> functional use case. But I will be using the TransportClient Java API, not  
> the REST client.
> 
> Can you please tell me how I can find/modify these classes/sources to get  
> the appropriate classes for inctercepting the Search Response when invoked  
> from a TransportClient?
> 
> Thanks,  
> Sandeep
> 
> On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> 
> > Have a look at array-format or csv plugin, they are processing the  
> > SearchResponse to output it in another format:
> > 
> > [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> > 
> > [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> > 
> > Jörg
> > 
> > On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> > elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> > 
> > > Hi,
> > > 
> > > Is there any action/module that I can extend/register/add so that I can  
> > > intercept the SearchResponse on the server node before the response is sent  
> > > back to the TransportClient on the calling box?
> > > 
> > > Thanks,  
> > > Sandeep
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Sandeep\_Ramesh\_Khanz](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@Sandeep\_Ramesh\_Khanz](https://discuss.elastic.co/u/Sandeep_Ramesh_Khanz)\
**Post date:** [September 11, 2014, 8:00am UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/5 "2014-09-11T08:00:14Z")

</div>

When you say, 'receive the SearchResponse', is that in the ES Server node  
or the TransportClient node that spawned the request? I would want to  
intercept the SearchResponse when created at the ES Server itself, since I  
want to send the subset of Response to another process on the same node,  
and it would not be very efficient to have the response sent back to the  
client node only to be sent back again.

Thanks,  
Sandeep

On Thu, Sep 11, 2014 at 12:43 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
[joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:

> You can receive the SearchResponse, process the response, and return the  
> response with whatever format you want.
> 
> Jörg
> 
> On Wed, Sep 10, 2014 at 11:59 AM, Sandeep Ramesh Khanzode \<  
> [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com)\> wrote:
> 
> > Hi Jorg,
> > 
> > Thanks for the links. I was checking the sources. There are relevant to  
> > my functional use case. But I will be using the TransportClient Java API,  
> > not the REST client.
> > 
> > Can you please tell me how I can find/modify these classes/sources to get  
> > the appropriate classes for inctercepting the Search Response when invoked  
> > from a TransportClient?
> > 
> > Thanks,  
> > Sandeep
> > 
> > On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> > [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> > 
> > > Have a look at array-format or csv plugin, they are processing the  
> > > SearchResponse to output it in another format:
> > > 
> > > [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> > > 
> > > [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> > > 
> > > Jörg
> > > 
> > > On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> > > elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> > > 
> > > > Hi,
> > > > 
> > > > Is there any action/module that I can extend/register/add so that I can  
> > > > intercept the SearchResponse on the server node before the response is sent  
> > > > back to the TransportClient on the calling box?
> > > > 
> > > > Thanks,  
> > > > Sandeep
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 11, 2014, 11:23am UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/6 "2014-09-11T11:23:55Z")

</div>

You can not intercept the SearchResponse on the ES server itself. Instead,  
you must implement your custom search action.

Jörg

On Thu, Sep 11, 2014 at 10:00 AM, Sandeep Ramesh Khanzode \<  
[k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com)\> wrote:

> When you say, 'receive the SearchResponse', is that in the ES Server node  
> or the TransportClient node that spawned the request? I would want to  
> intercept the SearchResponse when created at the ES Server itself, since I  
> want to send the subset of Response to another process on the same node,  
> and it would not be very efficient to have the response sent back to the  
> client node only to be sent back again.
> 
> Thanks,  
> Sandeep
> 
> On Thu, Sep 11, 2014 at 12:43 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> 
> > You can receive the SearchResponse, process the response, and return the  
> > response with whatever format you want.
> > 
> > Jörg
> > 
> > On Wed, Sep 10, 2014 at 11:59 AM, Sandeep Ramesh Khanzode \<  
> > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com)\> wrote:
> > 
> > > Hi Jorg,
> > > 
> > > Thanks for the links. I was checking the sources. There are relevant to  
> > > my functional use case. But I will be using the TransportClient Java API,  
> > > not the REST client.
> > > 
> > > Can you please tell me how I can find/modify these classes/sources to  
> > > get the appropriate classes for inctercepting the Search Response when  
> > > invoked from a TransportClient?
> > > 
> > > Thanks,  
> > > Sandeep
> > > 
> > > On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> > > [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> > > 
> > > > Have a look at array-format or csv plugin, they are processing the  
> > > > SearchResponse to output it in another format:
> > > > 
> > > > [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> > > > 
> > > > [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> > > > 
> > > > Jörg
> > > > 
> > > > On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> > > > elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> > > > 
> > > > > Hi,
> > > > > 
> > > > > Is there any action/module that I can extend/register/add so that I  
> > > > > can intercept the SearchResponse on the server node before the response is  
> > > > > sent back to the TransportClient on the calling box?
> > > > > 
> > > > > Thanks,  
> > > > > Sandeep
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > To view this discussion on the web visit  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .  
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit  
> > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe)  
> > > > .  
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Sandeep\_Ramesh\_Khanz](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@Sandeep\_Ramesh\_Khanz](https://discuss.elastic.co/u/Sandeep_Ramesh_Khanz)\
**Post date:** [September 11, 2014, 5:55pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/7 "2014-09-11T17:55:00Z")

</div>

Thanks for bearing with me till now 🙂 Please provide one final input on  
this issue.

Is there any example for a custom search action? If not, can you please  
provide some details on how I can implement one?

Thanks,  
Sandeep

On Thu, Sep 11, 2014 at 4:53 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
[joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:

> You can not intercept the SearchResponse on the ES server itself. Instead,  
> you must implement your custom search action.
> 
> Jörg
> 
> On Thu, Sep 11, 2014 at 10:00 AM, Sandeep Ramesh Khanzode \<  
> [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com)\> wrote:
> 
> > When you say, 'receive the SearchResponse', is that in the ES Server node  
> > or the TransportClient node that spawned the request? I would want to  
> > intercept the SearchResponse when created at the ES Server itself, since I  
> > want to send the subset of Response to another process on the same node,  
> > and it would not be very efficient to have the response sent back to the  
> > client node only to be sent back again.
> > 
> > Thanks,  
> > Sandeep
> > 
> > On Thu, Sep 11, 2014 at 12:43 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> > [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> > 
> > > You can receive the SearchResponse, process the response, and return the  
> > > response with whatever format you want.
> > > 
> > > Jörg
> > > 
> > > On Wed, Sep 10, 2014 at 11:59 AM, Sandeep Ramesh Khanzode \<  
> > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com)\> wrote:
> > > 
> > > > Hi Jorg,
> > > > 
> > > > Thanks for the links. I was checking the sources. There are relevant to  
> > > > my functional use case. But I will be using the TransportClient Java API,  
> > > > not the REST client.
> > > > 
> > > > Can you please tell me how I can find/modify these classes/sources to  
> > > > get the appropriate classes for inctercepting the Search Response when  
> > > > invoked from a TransportClient?
> > > > 
> > > > Thanks,  
> > > > Sandeep
> > > > 
> > > > On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> > > > [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> > > > 
> > > > > Have a look at array-format or csv plugin, they are processing the  
> > > > > SearchResponse to output it in another format:
> > > > > 
> > > > > [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> > > > > 
> > > > > [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> > > > > 
> > > > > Jörg
> > > > > 
> > > > > On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> > > > > elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> > > > > 
> > > > > > Hi,
> > > > > > 
> > > > > > Is there any action/module that I can extend/register/add so that I  
> > > > > > can intercept the SearchResponse on the server node before the response is  
> > > > > > sent back to the TransportClient on the calling box?
> > > > > > 
> > > > > > Thanks,  
> > > > > > Sandeep
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to the Google  
> > > > > > Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > To view this discussion on the web visit  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com)  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .  
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to a topic in the  
> > > > > Google Groups "elasticsearch" group.  
> > > > > To unsubscribe from this topic, visit  
> > > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe)  
> > > > > .  
> > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > To view this discussion on the web visit  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > > .
> > > > > 
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 11, 2014, 6:44pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/8 "2014-09-11T18:44:33Z")

</div>

Yes. I have checked in some code for a simple action plugin.

> **[GitHub - jprante/elasticsearch-simple-action-plugin: A simple action plugin...](https://github.com/jprante/elasticsearch-simple-action-plugin)**
>
> A simple action plugin for Elasticsearch. Contribute to jprante/elasticsearch-simple-action-plugin development by creating an account on GitHub.

The plugin implements a simple "match\_all" search action, by reusing much  
of the code of the search action.

Best,

Jörg

On Thu, Sep 11, 2014 at 7:55 PM, Sandeep Ramesh Khanzode \<  
[k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com)\> wrote:

> Thanks for bearing with me till now 🙂 Please provide one final input on  
> this issue.
> 
> Is there any example for a custom search action? If not, can you please  
> provide some details on how I can implement one?
> 
> Thanks,  
> Sandeep
> 
> On Thu, Sep 11, 2014 at 4:53 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> 
> > You can not intercept the SearchResponse on the ES server itself.  
> > Instead, you must implement your custom search action.
> > 
> > Jörg
> > 
> > On Thu, Sep 11, 2014 at 10:00 AM, Sandeep Ramesh Khanzode \<  
> > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com)\> wrote:
> > 
> > > When you say, 'receive the SearchResponse', is that in the ES Server  
> > > node or the TransportClient node that spawned the request? I would want to  
> > > intercept the SearchResponse when created at the ES Server itself, since I  
> > > want to send the subset of Response to another process on the same node,  
> > > and it would not be very efficient to have the response sent back to the  
> > > client node only to be sent back again.
> > > 
> > > Thanks,  
> > > Sandeep
> > > 
> > > On Thu, Sep 11, 2014 at 12:43 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> > > [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> > > 
> > > > You can receive the SearchResponse, process the response, and return  
> > > > the response with whatever format you want.
> > > > 
> > > > Jörg
> > > > 
> > > > On Wed, Sep 10, 2014 at 11:59 AM, Sandeep Ramesh Khanzode \<  
> > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com)\> wrote:
> > > > 
> > > > > Hi Jorg,
> > > > > 
> > > > > Thanks for the links. I was checking the sources. There are relevant  
> > > > > to my functional use case. But I will be using the TransportClient Java  
> > > > > API, not the REST client.
> > > > > 
> > > > > Can you please tell me how I can find/modify these classes/sources to  
> > > > > get the appropriate classes for inctercepting the Search Response when  
> > > > > invoked from a TransportClient?
> > > > > 
> > > > > Thanks,  
> > > > > Sandeep
> > > > > 
> > > > > On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> > > > > 
> > > > > > Have a look at array-format or csv plugin, they are processing the  
> > > > > > SearchResponse to output it in another format:
> > > > > > 
> > > > > > [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> > > > > > 
> > > > > > [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> > > > > > 
> > > > > > Jörg
> > > > > > 
> > > > > > On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> > > > > > elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> > > > > > 
> > > > > > > Hi,
> > > > > > > 
> > > > > > > Is there any action/module that I can extend/register/add so that I  
> > > > > > > can intercept the SearchResponse on the server node before the response is  
> > > > > > > sent back to the TransportClient on the calling box?
> > > > > > > 
> > > > > > > Thanks,  
> > > > > > > Sandeep
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to the Google  
> > > > > > > Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > To view this discussion on the web visit  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com)  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > > .  
> > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to a topic in  
> > > > > > the Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this topic, visit  
> > > > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe)  
> > > > > > .  
> > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > To view this discussion on the web visit  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com)  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > > > .
> > > > > > 
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > To view this discussion on the web visit  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > > .
> > > > > 
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit  
> > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe)  
> > > > .  
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH\_O75pf5\_ShaYy9rQy08NUYnvA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH_O75pf5_ShaYy9rQy08NUYnvA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tomislav\_Poljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomislav_poljak/32/1177_2.png) [@Tomislav\_Poljak](https://discuss.elastic.co/u/Tomislav_Poljak)\
**Post date:** [October 18, 2014, 10:55am UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/9 "2014-10-18T10:55:59Z")

</div>

Hi,  
if I understand correctly, seems it should be possible to use  
SimpleRequest over TransportClient, is this correct?

I couldn't get it to work using:

Client client = new TransportClient().addTransportAddress(new  
InetSocketTransportAddress("localhost", 9300));

but when switched to node client, seems to work

Node node = nodeBuilder().client(true).node();  
Client client = node.client();

I'm also interested in reducing results/aggs using some custom code,  
but to have it executed on elasticsearch cluster not to transfer  
results to client node and reduce it there, but I'm not sure if this  
is possible with custom transport actions when using TransportClient.

Any info on this would be appreciated,  
Tomislav

2014-09-11 20:44 GMT+02:00 [joergprante@gmail.com](mailto:joergprante@gmail.com) [joergprante@gmail.com](mailto:joergprante@gmail.com):

> Yes. I have checked in some code for a simple action plugin.
> 
> [GitHub - jprante/elasticsearch-simple-action-plugin: A simple action plugin for Elasticsearch](https://github.com/jprante/elasticsearch-simple-action-plugin)
> 
> The plugin implements a simple "match\_all" search action, by reusing much of  
> the code of the search action.
> 
> Best,
> 
> Jörg
> 
> On Thu, Sep 11, 2014 at 7:55 PM, Sandeep Ramesh Khanzode  
> [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> 
> > Thanks for bearing with me till now 🙂 Please provide one final input on  
> > this issue.
> > 
> > Is there any example for a custom search action? If not, can you please  
> > provide some details on how I can implement one?
> > 
> > Thanks,  
> > Sandeep
> > 
> > On Thu, Sep 11, 2014 at 4:53 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > 
> > > You can not intercept the SearchResponse on the ES server itself.  
> > > Instead, you must implement your custom search action.
> > > 
> > > Jörg
> > > 
> > > On Thu, Sep 11, 2014 at 10:00 AM, Sandeep Ramesh Khanzode  
> > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > 
> > > > When you say, 'receive the SearchResponse', is that in the ES Server  
> > > > node or the TransportClient node that spawned the request? I would want to  
> > > > intercept the SearchResponse when created at the ES Server itself, since I  
> > > > want to send the subset of Response to another process on the same node, and  
> > > > it would not be very efficient to have the response sent back to the client  
> > > > node only to be sent back again.
> > > > 
> > > > Thanks,  
> > > > Sandeep
> > > > 
> > > > On Thu, Sep 11, 2014 at 12:43 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > 
> > > > > You can receive the SearchResponse, process the response, and return  
> > > > > the response with whatever format you want.
> > > > > 
> > > > > Jörg
> > > > > 
> > > > > On Wed, Sep 10, 2014 at 11:59 AM, Sandeep Ramesh Khanzode  
> > > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > > 
> > > > > > Hi Jorg,
> > > > > > 
> > > > > > Thanks for the links. I was checking the sources. There are relevant  
> > > > > > to my functional use case. But I will be using the TransportClient Java API,  
> > > > > > not the REST client.
> > > > > > 
> > > > > > Can you please tell me how I can find/modify these classes/sources to  
> > > > > > get the appropriate classes for inctercepting the Search Response when  
> > > > > > invoked from a TransportClient?
> > > > > > 
> > > > > > Thanks,  
> > > > > > Sandeep
> > > > > > 
> > > > > > On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > > 
> > > > > > > Have a look at array-format or csv plugin, they are processing the  
> > > > > > > SearchResponse to output it in another format:
> > > > > > > 
> > > > > > > [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> > > > > > > 
> > > > > > > [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> > > > > > > 
> > > > > > > Jörg
> > > > > > > 
> > > > > > > On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> > > > > > > elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> > > > > > > 
> > > > > > > > Hi,
> > > > > > > > 
> > > > > > > > Is there any action/module that I can extend/register/add so that I  
> > > > > > > > can intercept the SearchResponse on the server node before the response is  
> > > > > > > > sent back to the TransportClient on the calling box?
> > > > > > > > 
> > > > > > > > Thanks,  
> > > > > > > > Sandeep
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > You received this message because you are subscribed to the Google  
> > > > > > > > Groups "elasticsearch" group.  
> > > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > > send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > To view this discussion on the web visit  
> > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com).  
> > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to a topic in  
> > > > > > > the Google Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this topic, visit  
> > > > > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > To view this discussion on the web visit  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com).
> > > > > > > 
> > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to the Google  
> > > > > > Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > To view this discussion on the web visit  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com).
> > > > > > 
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to a topic in the  
> > > > > Google Groups "elasticsearch" group.  
> > > > > To unsubscribe from this topic, visit  
> > > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > To view this discussion on the web visit  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com).
> > > > > 
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com).
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com).
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH\_O75pf5\_ShaYy9rQy08NUYnvA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH_O75pf5_ShaYy9rQy08NUYnvA%40mail.gmail.com).
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALuCJxhZ6t\_7hx30QoD30f3B3erP499JSHCTGxAQvJ518fFv8A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALuCJxhZ6t_7hx30QoD30f3B3erP499JSHCTGxAQvJ518fFv8A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [October 18, 2014, 1:28pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/10 "2014-10-18T13:28:11Z")

</div>

You must set up a cluster name in the settings for the TransportClient,  
otherwise connection requests will be rejected by the cluster.

Also, a dynmaic "new TransportClient()" for client instantiation is  
discouraged. By doing this, you open up a new threadpool each time.  
Recommend is to use a singleton instantiation for the whole JVM, and a  
single close() call on the TransportClient instance when JVM exits.

Jörg

On Sat, Oct 18, 2014 at 12:55 PM, Tomislav Poljak [tpoljak@gmail.com](mailto:tpoljak@gmail.com) wrote:

> Hi,  
> if I understand correctly, seems it should be possible to use  
> SimpleRequest over TransportClient, is this correct?
> 
> I couldn't get it to work using:
> 
> Client client = new TransportClient().addTransportAddress(new  
> InetSocketTransportAddress("localhost", 9300));
> 
> but when switched to node client, seems to work
> 
> Node node = nodeBuilder().client(true).node();  
> Client client = node.client();
> 
> I'm also interested in reducing results/aggs using some custom code,  
> but to have it executed on elasticsearch cluster not to transfer  
> results to client node and reduce it there, but I'm not sure if this  
> is possible with custom transport actions when using TransportClient.
> 
> Any info on this would be appreciated,  
> Tomislav
> 
> 2014-09-11 20:44 GMT+02:00 [joergprante@gmail.com](mailto:joergprante@gmail.com) [joergprante@gmail.com](mailto:joergprante@gmail.com):
> 
> > Yes. I have checked in some code for a simple action plugin.
> > 
> > [GitHub - jprante/elasticsearch-simple-action-plugin: A simple action plugin for Elasticsearch](https://github.com/jprante/elasticsearch-simple-action-plugin)
> > 
> > The plugin implements a simple "match\_all" search action, by reusing  
> > much of  
> > the code of the search action.
> > 
> > Best,
> > 
> > Jörg
> > 
> > On Thu, Sep 11, 2014 at 7:55 PM, Sandeep Ramesh Khanzode  
> > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > 
> > > Thanks for bearing with me till now 🙂 Please provide one final input on  
> > > this issue.
> > > 
> > > Is there any example for a custom search action? If not, can you please  
> > > provide some details on how I can implement one?
> > > 
> > > Thanks,  
> > > Sandeep
> > > 
> > > On Thu, Sep 11, 2014 at 4:53 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > 
> > > > You can not intercept the SearchResponse on the ES server itself.  
> > > > Instead, you must implement your custom search action.
> > > > 
> > > > Jörg
> > > > 
> > > > On Thu, Sep 11, 2014 at 10:00 AM, Sandeep Ramesh Khanzode  
> > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > 
> > > > > When you say, 'receive the SearchResponse', is that in the ES Server  
> > > > > node or the TransportClient node that spawned the request? I would  
> > > > > want to  
> > > > > intercept the SearchResponse when created at the ES Server itself,  
> > > > > since I  
> > > > > want to send the subset of Response to another process on the same  
> > > > > node, and  
> > > > > it would not be very efficient to have the response sent back to the  
> > > > > client  
> > > > > node only to be sent back again.
> > > > > 
> > > > > Thanks,  
> > > > > Sandeep
> > > > > 
> > > > > On Thu, Sep 11, 2014 at 12:43 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > 
> > > > > > You can receive the SearchResponse, process the response, and return  
> > > > > > the response with whatever format you want.
> > > > > > 
> > > > > > Jörg
> > > > > > 
> > > > > > On Wed, Sep 10, 2014 at 11:59 AM, Sandeep Ramesh Khanzode  
> > > > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > > > 
> > > > > > > Hi Jorg,
> > > > > > > 
> > > > > > > Thanks for the links. I was checking the sources. There are relevant  
> > > > > > > to my functional use case. But I will be using the TransportClient  
> > > > > > > Java API,  
> > > > > > > not the REST client.
> > > > > > > 
> > > > > > > Can you please tell me how I can find/modify these classes/sources  
> > > > > > > to  
> > > > > > > get the appropriate classes for inctercepting the Search Response  
> > > > > > > when  
> > > > > > > invoked from a TransportClient?
> > > > > > > 
> > > > > > > Thanks,  
> > > > > > > Sandeep
> > > > > > > 
> > > > > > > On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > > > 
> > > > > > > > Have a look at array-format or csv plugin, they are processing the  
> > > > > > > > SearchResponse to output it in another format:
> > > > > > > > 
> > > > > > > > [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> > > > > > > > 
> > > > > > > > [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> > > > > > > > 
> > > > > > > > Jörg
> > > > > > > > 
> > > > > > > > On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> > > > > > > > elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> > > > > > > > 
> > > > > > > > > Hi,
> > > > > > > > > 
> > > > > > > > > Is there any action/module that I can extend/register/add so that  
> > > > > > > > > I  
> > > > > > > > > can intercept the SearchResponse on the server node before the  
> > > > > > > > > response is  
> > > > > > > > > sent back to the TransportClient on the calling box?
> > > > > > > > > 
> > > > > > > > > Thanks,  
> > > > > > > > > Sandeep
> > > > > > > > > 
> > > > > > > > > --  
> > > > > > > > > You received this message because you are subscribed to the Google  
> > > > > > > > > Groups "elasticsearch" group.  
> > > > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > > > send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com)  
> .
> 
> > > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > You received this message because you are subscribed to a topic in  
> > > > > > > > the Google Groups "elasticsearch" group.  
> > > > > > > > To unsubscribe from this topic, visit
> 
> [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).
> 
> > > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com)  
> .
> 
> > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to the Google  
> > > > > > > Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > send  
> > > > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com)  
> .
> 
> > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to a topic in  
> > > > > > the  
> > > > > > Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this topic, visit
> 
> [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).
> 
> > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com)  
> .
> 
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com)  
> .
> 
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit
> 
> [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).
> 
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com)  
> .
> 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an  
> > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com)  
> .
> 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH\_O75pf5\_ShaYy9rQy08NUYnvA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH_O75pf5_ShaYy9rQy08NUYnvA%40mail.gmail.com)  
> .
> 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CALuCJxhZ6t\_7hx30QoD30f3B3erP499JSHCTGxAQvJ518fFv8A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALuCJxhZ6t_7hx30QoD30f3B3erP499JSHCTGxAQvJ518fFv8A%40mail.gmail.com)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEkFOeT4x7qi365MQ8Kz6f1YXWMc0-vV%2B0ur9PBYDAWSg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEkFOeT4x7qi365MQ8Kz6f1YXWMc0-vV%2B0ur9PBYDAWSg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tomislav\_Poljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomislav_poljak/32/1177_2.png) [@Tomislav\_Poljak](https://discuss.elastic.co/u/Tomislav_Poljak)\
**Post date:** [October 20, 2014, 1:09pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/11 "2014-10-20T13:09:22Z")

</div>

Hi Jörg,  
thanks for response!

I use default 'elasticsearch' cluster name and 'ordinary' match\_all (as below)

Client client = new TransportClient().addTransportAddress(new  
InetSocketTransportAddress("localhost", 9300));  
SearchResponse response = client.prepareSearch().execute().actionGet();

works fine (connects,executes and returns results). However, I can't  
execute SimpleAction successfully over TransportClient (even with  
cluster name set):

Client client = new  
TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
"elasticsearch")).addTransportAddress(new  
InetSocketTransportAddress("localhost", 9300));

SimpleRequestBuilder builder = new SimpleRequestBuilder(client);  
SearchResponse response = client.execute(SimpleAction.INSTANCE,  
builder.request()).actionGet();

Both, elasticsearch server and client using TransportClient report  
'simple action' plugin loaded (in console INFO), but on execute I get  
NPE on the client's side with trace:

org.elasticsearch.common.util.concurrent.UncategorizedExecutionException:  
Failed execution  
at org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90)  
at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:50)  
at org.xbib.elasticsearch.action.simple.SimpleActionTest.testSimpleAction(SimpleActionTest.java:26)  
..

Caused by: java.lang.NullPointerException  
at org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:541)  
at org.xbib.elasticsearch.action.simple.SimpleRequest.writeTo(SimpleRequest.java:38)

Am I missing or misunderstanding something?

Tomislav

2014-10-18 15:28 GMT+02:00 [joergprante@gmail.com](mailto:joergprante@gmail.com) [joergprante@gmail.com](mailto:joergprante@gmail.com):

> You must set up a cluster name in the settings for the TransportClient,  
> otherwise connection requests will be rejected by the cluster.
> 
> Also, a dynmaic "new TransportClient()" for client instantiation is  
> discouraged. By doing this, you open up a new threadpool each time.  
> Recommend is to use a singleton instantiation for the whole JVM, and a  
> single close() call on the TransportClient instance when JVM exits.
> 
> Jörg
> 
> On Sat, Oct 18, 2014 at 12:55 PM, Tomislav Poljak [tpoljak@gmail.com](mailto:tpoljak@gmail.com) wrote:
> 
> > Hi,  
> > if I understand correctly, seems it should be possible to use  
> > SimpleRequest over TransportClient, is this correct?
> > 
> > I couldn't get it to work using:
> > 
> > Client client = new TransportClient().addTransportAddress(new  
> > InetSocketTransportAddress("localhost", 9300));
> > 
> > but when switched to node client, seems to work
> > 
> > Node node = nodeBuilder().client(true).node();  
> > Client client = node.client();
> > 
> > I'm also interested in reducing results/aggs using some custom code,  
> > but to have it executed on elasticsearch cluster not to transfer  
> > results to client node and reduce it there, but I'm not sure if this  
> > is possible with custom transport actions when using TransportClient.
> > 
> > Any info on this would be appreciated,  
> > Tomislav
> > 
> > 2014-09-11 20:44 GMT+02:00 [joergprante@gmail.com](mailto:joergprante@gmail.com) [joergprante@gmail.com](mailto:joergprante@gmail.com):
> > 
> > > Yes. I have checked in some code for a simple action plugin.
> > > 
> > > [GitHub - jprante/elasticsearch-simple-action-plugin: A simple action plugin for Elasticsearch](https://github.com/jprante/elasticsearch-simple-action-plugin)
> > > 
> > > The plugin implements a simple "match\_all" search action, by reusing  
> > > much of  
> > > the code of the search action.
> > > 
> > > Best,
> > > 
> > > Jörg
> > > 
> > > On Thu, Sep 11, 2014 at 7:55 PM, Sandeep Ramesh Khanzode  
> > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > 
> > > > Thanks for bearing with me till now 🙂 Please provide one final input  
> > > > on  
> > > > this issue.
> > > > 
> > > > Is there any example for a custom search action? If not, can you please  
> > > > provide some details on how I can implement one?
> > > > 
> > > > Thanks,  
> > > > Sandeep
> > > > 
> > > > On Thu, Sep 11, 2014 at 4:53 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > 
> > > > > You can not intercept the SearchResponse on the ES server itself.  
> > > > > Instead, you must implement your custom search action.
> > > > > 
> > > > > Jörg
> > > > > 
> > > > > On Thu, Sep 11, 2014 at 10:00 AM, Sandeep Ramesh Khanzode  
> > > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > > 
> > > > > > When you say, 'receive the SearchResponse', is that in the ES Server  
> > > > > > node or the TransportClient node that spawned the request? I would  
> > > > > > want to  
> > > > > > intercept the SearchResponse when created at the ES Server itself,  
> > > > > > since I  
> > > > > > want to send the subset of Response to another process on the same  
> > > > > > node, and  
> > > > > > it would not be very efficient to have the response sent back to the  
> > > > > > client  
> > > > > > node only to be sent back again.
> > > > > > 
> > > > > > Thanks,  
> > > > > > Sandeep
> > > > > > 
> > > > > > On Thu, Sep 11, 2014 at 12:43 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > > 
> > > > > > > You can receive the SearchResponse, process the response, and return  
> > > > > > > the response with whatever format you want.
> > > > > > > 
> > > > > > > Jörg
> > > > > > > 
> > > > > > > On Wed, Sep 10, 2014 at 11:59 AM, Sandeep Ramesh Khanzode  
> > > > > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > > > > 
> > > > > > > > Hi Jorg,
> > > > > > > > 
> > > > > > > > Thanks for the links. I was checking the sources. There are  
> > > > > > > > relevant  
> > > > > > > > to my functional use case. But I will be using the TransportClient  
> > > > > > > > Java API,  
> > > > > > > > not the REST client.
> > > > > > > > 
> > > > > > > > Can you please tell me how I can find/modify these classes/sources  
> > > > > > > > to  
> > > > > > > > get the appropriate classes for inctercepting the Search Response  
> > > > > > > > when  
> > > > > > > > invoked from a TransportClient?
> > > > > > > > 
> > > > > > > > Thanks,  
> > > > > > > > Sandeep
> > > > > > > > 
> > > > > > > > On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > > > > 
> > > > > > > > > Have a look at array-format or csv plugin, they are processing the  
> > > > > > > > > SearchResponse to output it in another format:
> > > > > > > > > 
> > > > > > > > > [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> > > > > > > > > 
> > > > > > > > > [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> > > > > > > > > 
> > > > > > > > > Jörg
> > > > > > > > > 
> > > > > > > > > On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> > > > > > > > > elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> > > > > > > > > 
> > > > > > > > > > Hi,
> > > > > > > > > > 
> > > > > > > > > > Is there any action/module that I can extend/register/add so that  
> > > > > > > > > > I  
> > > > > > > > > > can intercept the SearchResponse on the server node before the  
> > > > > > > > > > response is  
> > > > > > > > > > sent back to the TransportClient on the calling box?
> > > > > > > > > > 
> > > > > > > > > > Thanks,  
> > > > > > > > > > Sandeep
> > > > > > > > > > 
> > > > > > > > > > --  
> > > > > > > > > > You received this message because you are subscribed to the  
> > > > > > > > > > Google  
> > > > > > > > > > Groups "elasticsearch" group.  
> > > > > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > > > > send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > > > To view this discussion on the web visit
> > > > > > > > > > 
> > > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com).  
> > > > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > > > 
> > > > > > > > > --  
> > > > > > > > > You received this message because you are subscribed to a topic in  
> > > > > > > > > the Google Groups "elasticsearch" group.  
> > > > > > > > > To unsubscribe from this topic, visit
> > > > > > > > > 
> > > > > > > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > > > > > > > To unsubscribe from this group and all its topics, send an email  
> > > > > > > > > to  
> > > > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > > To view this discussion on the web visit
> > > > > > > > > 
> > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com).
> > > > > > > > > 
> > > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > You received this message because you are subscribed to the Google  
> > > > > > > > Groups "elasticsearch" group.  
> > > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > > send  
> > > > > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > To view this discussion on the web visit
> > > > > > > > 
> > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com).
> > > > > > > > 
> > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to a topic in  
> > > > > > > the  
> > > > > > > Google Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this topic, visit
> > > > > > > 
> > > > > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > To view this discussion on the web visit
> > > > > > > 
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com).
> > > > > > > 
> > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to the Google  
> > > > > > Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > send  
> > > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > To view this discussion on the web visit
> > > > > > 
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com).
> > > > > > 
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to a topic in the  
> > > > > Google Groups "elasticsearch" group.  
> > > > > To unsubscribe from this topic, visit
> > > > > 
> > > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > To view this discussion on the web visit
> > > > > 
> > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com).
> > > > > 
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups  
> > > > "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an  
> > > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > To view this discussion on the web visit
> > > > 
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an  
> > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit
> > > 
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH\_O75pf5\_ShaYy9rQy08NUYnvA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH_O75pf5_ShaYy9rQy08NUYnvA%40mail.gmail.com).
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CALuCJxhZ6t\_7hx30QoD30f3B3erP499JSHCTGxAQvJ518fFv8A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALuCJxhZ6t_7hx30QoD30f3B3erP499JSHCTGxAQvJ518fFv8A%40mail.gmail.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEkFOeT4x7qi365MQ8Kz6f1YXWMc0-vV%2B0ur9PBYDAWSg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEkFOeT4x7qi365MQ8Kz6f1YXWMc0-vV%2B0ur9PBYDAWSg%40mail.gmail.com).
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALuCJxgt25g1RHJuaVSZ37LLw-%3D%2BDAD0hY6gS8kCGh3zG\_4KUQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALuCJxgt25g1RHJuaVSZ37LLw-%3D%2BDAD0hY6gS8kCGh3zG_4KUQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [October 20, 2014, 3:21pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/12 "2014-10-20T15:21:47Z")

</div>

If you use TransportClient, implementing custom actions like SimpleAction  
gets a bit tricky: you must install the plugin both on the cluster on all  
nodes _and_ on the TransportClient classpath.

The reason is, the TransportClient initiates a proxy action to ask the  
cluster to execute the action for him. A NodeClient runs in a single JVM  
with a cluster node and does not need such a proxy action.

Jörg

On Mon, Oct 20, 2014 at 3:09 PM, Tomislav Poljak [tpoljak@gmail.com](mailto:tpoljak@gmail.com) wrote:

> Hi Jörg,  
> thanks for response!
> 
> I use default 'elasticsearch' cluster name and 'ordinary' match\_all (as  
> below)
> 
> Client client = new TransportClient().addTransportAddress(new  
> InetSocketTransportAddress("localhost", 9300));  
> SearchResponse response = client.prepareSearch().execute().actionGet();
> 
> works fine (connects,executes and returns results). However, I can't  
> execute SimpleAction successfully over TransportClient (even with  
> cluster name set):
> 
> Client client = new  
> TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
> "elasticsearch")).addTransportAddress(new  
> InetSocketTransportAddress("localhost", 9300));
> 
> SimpleRequestBuilder builder = new SimpleRequestBuilder(client);  
> SearchResponse response = client.execute(SimpleAction.INSTANCE,  
> builder.request()).actionGet();
> 
> Both, elasticsearch server and client using TransportClient report  
> 'simple action' plugin loaded (in console INFO), but on execute I get  
> NPE on the client's side with trace:
> 
> org.elasticsearch.common.util.concurrent.UncategorizedExecutionException:  
> Failed execution  
> at  
> org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90)  
> at  
> org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:50)  
> at  
> org.xbib.elasticsearch.action.simple.SimpleActionTest.testSimpleAction(SimpleActionTest.java:26)  
> ..
> 
> Caused by: java.lang.NullPointerException  
> at  
> org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:541)  
> at  
> org.xbib.elasticsearch.action.simple.SimpleRequest.writeTo(SimpleRequest.java:38)
> 
> Am I missing or misunderstanding something?
> 
> Tomislav
> 
> 2014-10-18 15:28 GMT+02:00 [joergprante@gmail.com](mailto:joergprante@gmail.com) [joergprante@gmail.com](mailto:joergprante@gmail.com):
> 
> > You must set up a cluster name in the settings for the TransportClient,  
> > otherwise connection requests will be rejected by the cluster.
> > 
> > Also, a dynmaic "new TransportClient()" for client instantiation is  
> > discouraged. By doing this, you open up a new threadpool each time.  
> > Recommend is to use a singleton instantiation for the whole JVM, and a  
> > single close() call on the TransportClient instance when JVM exits.
> > 
> > Jörg
> > 
> > On Sat, Oct 18, 2014 at 12:55 PM, Tomislav Poljak [tpoljak@gmail.com](mailto:tpoljak@gmail.com)  
> > wrote:
> > 
> > > Hi,  
> > > if I understand correctly, seems it should be possible to use  
> > > SimpleRequest over TransportClient, is this correct?
> > > 
> > > I couldn't get it to work using:
> > > 
> > > Client client = new TransportClient().addTransportAddress(new  
> > > InetSocketTransportAddress("localhost", 9300));
> > > 
> > > but when switched to node client, seems to work
> > > 
> > > Node node = nodeBuilder().client(true).node();  
> > > Client client = node.client();
> > > 
> > > I'm also interested in reducing results/aggs using some custom code,  
> > > but to have it executed on elasticsearch cluster not to transfer  
> > > results to client node and reduce it there, but I'm not sure if this  
> > > is possible with custom transport actions when using TransportClient.
> > > 
> > > Any info on this would be appreciated,  
> > > Tomislav
> > > 
> > > 2014-09-11 20:44 GMT+02:00 [joergprante@gmail.com](mailto:joergprante@gmail.com) \<[joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > :
> > > 
> > > > Yes. I have checked in some code for a simple action plugin.
> > > > 
> > > > [GitHub - jprante/elasticsearch-simple-action-plugin: A simple action plugin for Elasticsearch](https://github.com/jprante/elasticsearch-simple-action-plugin)
> > > > 
> > > > The plugin implements a simple "match\_all" search action, by reusing  
> > > > much of  
> > > > the code of the search action.
> > > > 
> > > > Best,
> > > > 
> > > > Jörg
> > > > 
> > > > On Thu, Sep 11, 2014 at 7:55 PM, Sandeep Ramesh Khanzode  
> > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > 
> > > > > Thanks for bearing with me till now 🙂 Please provide one final input  
> > > > > on  
> > > > > this issue.
> > > > > 
> > > > > Is there any example for a custom search action? If not, can you  
> > > > > please  
> > > > > provide some details on how I can implement one?
> > > > > 
> > > > > Thanks,  
> > > > > Sandeep
> > > > > 
> > > > > On Thu, Sep 11, 2014 at 4:53 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > 
> > > > > > You can not intercept the SearchResponse on the ES server itself.  
> > > > > > Instead, you must implement your custom search action.
> > > > > > 
> > > > > > Jörg
> > > > > > 
> > > > > > On Thu, Sep 11, 2014 at 10:00 AM, Sandeep Ramesh Khanzode  
> > > > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > > > 
> > > > > > > When you say, 'receive the SearchResponse', is that in the ES  
> > > > > > > Server  
> > > > > > > node or the TransportClient node that spawned the request? I would  
> > > > > > > want to  
> > > > > > > intercept the SearchResponse when created at the ES Server itself,  
> > > > > > > since I  
> > > > > > > want to send the subset of Response to another process on the same  
> > > > > > > node, and  
> > > > > > > it would not be very efficient to have the response sent back to  
> > > > > > > the  
> > > > > > > client  
> > > > > > > node only to be sent back again.
> > > > > > > 
> > > > > > > Thanks,  
> > > > > > > Sandeep
> > > > > > > 
> > > > > > > On Thu, Sep 11, 2014 at 12:43 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > > > 
> > > > > > > > You can receive the SearchResponse, process the response, and  
> > > > > > > > return  
> > > > > > > > the response with whatever format you want.
> > > > > > > > 
> > > > > > > > Jörg
> > > > > > > > 
> > > > > > > > On Wed, Sep 10, 2014 at 11:59 AM, Sandeep Ramesh Khanzode  
> > > > > > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > > > > > 
> > > > > > > > > Hi Jorg,
> > > > > > > > > 
> > > > > > > > > Thanks for the links. I was checking the sources. There are  
> > > > > > > > > relevant  
> > > > > > > > > to my functional use case. But I will be using the  
> > > > > > > > > TransportClient  
> > > > > > > > > Java API,  
> > > > > > > > > not the REST client.
> > > > > > > > > 
> > > > > > > > > Can you please tell me how I can find/modify these  
> > > > > > > > > classes/sources  
> > > > > > > > > to  
> > > > > > > > > get the appropriate classes for inctercepting the Search Response  
> > > > > > > > > when  
> > > > > > > > > invoked from a TransportClient?
> > > > > > > > > 
> > > > > > > > > Thanks,  
> > > > > > > > > Sandeep
> > > > > > > > > 
> > > > > > > > > On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > > > > > 
> > > > > > > > > > Have a look at array-format or csv plugin, they are processing  
> > > > > > > > > > the  
> > > > > > > > > > SearchResponse to output it in another format:
> > > > > > > > > > 
> > > > > > > > > > [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> > > > > > > > > > 
> > > > > > > > > > [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> > > > > > > > > > 
> > > > > > > > > > Jörg
> > > > > > > > > > 
> > > > > > > > > > On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> > > > > > > > > > elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> > > > > > > > > > 
> > > > > > > > > > > Hi,
> > > > > > > > > > > 
> > > > > > > > > > > Is there any action/module that I can extend/register/add so  
> > > > > > > > > > > that  
> > > > > > > > > > > I  
> > > > > > > > > > > can intercept the SearchResponse on the server node before the  
> > > > > > > > > > > response is  
> > > > > > > > > > > sent back to the TransportClient on the calling box?
> > > > > > > > > > > 
> > > > > > > > > > > Thanks,  
> > > > > > > > > > > Sandeep
> > > > > > > > > > > 
> > > > > > > > > > > --  
> > > > > > > > > > > You received this message because you are subscribed to the  
> > > > > > > > > > > Google  
> > > > > > > > > > > Groups "elasticsearch" group.  
> > > > > > > > > > > To unsubscribe from this group and stop receiving emails from  
> > > > > > > > > > > it,  
> > > > > > > > > > > send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com)  
> .
> 
> > > > > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > > > > 
> > > > > > > > > > --  
> > > > > > > > > > You received this message because you are subscribed to a topic  
> > > > > > > > > > in  
> > > > > > > > > > the Google Groups "elasticsearch" group.  
> > > > > > > > > > To unsubscribe from this topic, visit
> 
> [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).
> 
> > > > > > > > > > To unsubscribe from this group and all its topics, send an email  
> > > > > > > > > > to  
> > > > > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com)  
> .
> 
> > > > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > > > 
> > > > > > > > > --  
> > > > > > > > > You received this message because you are subscribed to the  
> > > > > > > > > Google  
> > > > > > > > > Groups "elasticsearch" group.  
> > > > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > > > send  
> > > > > > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com)  
> .
> 
> > > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > You received this message because you are subscribed to a topic in  
> > > > > > > > the  
> > > > > > > > Google Groups "elasticsearch" group.  
> > > > > > > > To unsubscribe from this topic, visit
> 
> [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).
> 
> > > > > > > > To unsubscribe from this group and all its topics, send an email  
> > > > > > > > to  
> > > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com)  
> .
> 
> > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to the Google  
> > > > > > > Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > send  
> > > > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com)  
> .
> 
> > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to a topic in  
> > > > > > the  
> > > > > > Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this topic, visit
> 
> [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).
> 
> > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com)  
> .
> 
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups  
> > > > > "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > send  
> > > > > an  
> > > > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com)  
> .
> 
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups  
> > > > "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an  
> > > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH\_O75pf5\_ShaYy9rQy08NUYnvA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH_O75pf5_ShaYy9rQy08NUYnvA%40mail.gmail.com)  
> .
> 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an  
> > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CALuCJxhZ6t\_7hx30QoD30f3B3erP499JSHCTGxAQvJ518fFv8A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALuCJxhZ6t_7hx30QoD30f3B3erP499JSHCTGxAQvJ518fFv8A%40mail.gmail.com)  
> .
> 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEkFOeT4x7qi365MQ8Kz6f1YXWMc0-vV%2B0ur9PBYDAWSg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEkFOeT4x7qi365MQ8Kz6f1YXWMc0-vV%2B0ur9PBYDAWSg%40mail.gmail.com)  
> .
> 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CALuCJxgt25g1RHJuaVSZ37LLw-%3D%2BDAD0hY6gS8kCGh3zG\_4KUQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALuCJxgt25g1RHJuaVSZ37LLw-%3D%2BDAD0hY6gS8kCGh3zG_4KUQ%40mail.gmail.com)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHG8-iLuR90BWc9Lc1CLF20892bnOWV18P%3Df0ktY0tayA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHG8-iLuR90BWc9Lc1CLF20892bnOWV18P%3Df0ktY0tayA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tomislav\_Poljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomislav_poljak/32/1177_2.png) [@Tomislav\_Poljak](https://discuss.elastic.co/u/Tomislav_Poljak)\
**Post date:** [October 20, 2014, 4:10pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/13 "2014-10-20T16:10:47Z")

</div>

Hi Jörg,  
I understand and what you described is exactly what I did: deployed  
plugin to both elasticsearch node/server (running single node cluster  
atm) and to the client code classpath which uses TransportClient -\>  
both log INFO 'simple action plugin loaded' on start, yet I can't  
execute simple action successfully from client using TransportClient  
(without NPE).

So, I'm wondering if custom actions can be executed thru the  
TransportClient at all or are custom TransportActions actually  
'internal node actions' which can only be executed on node (which  
expands query and reduces results from other nodes/shards on the  
client node - inside client jvm).

I wonder because seems to me like its not even plugin loading related  
issue, but actually a problem of 'internal' type of call execution -\>  
for example, I get the same NPE when executing typical search request  
using SearchAction.INSTANCE 'internal approach':

SearchRequestBuilder builder = new SearchRequestBuilder(client);  
SearchResponse response = client.execute(SearchAction.INSTANCE,  
builder.request()).actionGet();

over TransportClient, while again this call works perfectly fine over  
node client.

Do you have some setup where you consume custom actions using  
TransportClient (not rest and not node type of client)?

Thanks,  
Tomislav

2014-10-20 17:21 GMT+02:00 [joergprante@gmail.com](mailto:joergprante@gmail.com) [joergprante@gmail.com](mailto:joergprante@gmail.com):

> If you use TransportClient, implementing custom actions like SimpleAction  
> gets a bit tricky: you must install the plugin both on the cluster on all  
> nodes _and_ on the TransportClient classpath.
> 
> The reason is, the TransportClient initiates a proxy action to ask the  
> cluster to execute the action for him. A NodeClient runs in a single JVM  
> with a cluster node and does not need such a proxy action.
> 
> Jörg
> 
> On Mon, Oct 20, 2014 at 3:09 PM, Tomislav Poljak [tpoljak@gmail.com](mailto:tpoljak@gmail.com) wrote:
> 
> > Hi Jörg,  
> > thanks for response!
> > 
> > I use default 'elasticsearch' cluster name and 'ordinary' match\_all (as  
> > below)
> > 
> > Client client = new TransportClient().addTransportAddress(new  
> > InetSocketTransportAddress("localhost", 9300));  
> > SearchResponse response = client.prepareSearch().execute().actionGet();
> > 
> > works fine (connects,executes and returns results). However, I can't  
> > execute SimpleAction successfully over TransportClient (even with  
> > cluster name set):
> > 
> > Client client = new  
> > TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
> > "elasticsearch")).addTransportAddress(new  
> > InetSocketTransportAddress("localhost", 9300));
> > 
> > SimpleRequestBuilder builder = new SimpleRequestBuilder(client);  
> > SearchResponse response = client.execute(SimpleAction.INSTANCE,  
> > builder.request()).actionGet();
> > 
> > Both, elasticsearch server and client using TransportClient report  
> > 'simple action' plugin loaded (in console INFO), but on execute I get  
> > NPE on the client's side with trace:
> > 
> > org.elasticsearch.common.util.concurrent.UncategorizedExecutionException:  
> > Failed execution  
> > at  
> > org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90)  
> > at  
> > org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:50)  
> > at  
> > org.xbib.elasticsearch.action.simple.SimpleActionTest.testSimpleAction(SimpleActionTest.java:26)  
> > ..
> > 
> > Caused by: java.lang.NullPointerException  
> > at  
> > org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:541)  
> > at  
> > org.xbib.elasticsearch.action.simple.SimpleRequest.writeTo(SimpleRequest.java:38)
> > 
> > Am I missing or misunderstanding something?
> > 
> > Tomislav
> > 
> > 2014-10-18 15:28 GMT+02:00 [joergprante@gmail.com](mailto:joergprante@gmail.com) [joergprante@gmail.com](mailto:joergprante@gmail.com):
> > 
> > > You must set up a cluster name in the settings for the TransportClient,  
> > > otherwise connection requests will be rejected by the cluster.
> > > 
> > > Also, a dynmaic "new TransportClient()" for client instantiation is  
> > > discouraged. By doing this, you open up a new threadpool each time.  
> > > Recommend is to use a singleton instantiation for the whole JVM, and a  
> > > single close() call on the TransportClient instance when JVM exits.
> > > 
> > > Jörg
> > > 
> > > On Sat, Oct 18, 2014 at 12:55 PM, Tomislav Poljak [tpoljak@gmail.com](mailto:tpoljak@gmail.com)  
> > > wrote:
> > > 
> > > > Hi,  
> > > > if I understand correctly, seems it should be possible to use  
> > > > SimpleRequest over TransportClient, is this correct?
> > > > 
> > > > I couldn't get it to work using:
> > > > 
> > > > Client client = new TransportClient().addTransportAddress(new  
> > > > InetSocketTransportAddress("localhost", 9300));
> > > > 
> > > > but when switched to node client, seems to work
> > > > 
> > > > Node node = nodeBuilder().client(true).node();  
> > > > Client client = node.client();
> > > > 
> > > > I'm also interested in reducing results/aggs using some custom code,  
> > > > but to have it executed on elasticsearch cluster not to transfer  
> > > > results to client node and reduce it there, but I'm not sure if this  
> > > > is possible with custom transport actions when using TransportClient.
> > > > 
> > > > Any info on this would be appreciated,  
> > > > Tomislav
> > > > 
> > > > 2014-09-11 20:44 GMT+02:00 [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > [joergprante@gmail.com](mailto:joergprante@gmail.com):
> > > > 
> > > > > Yes. I have checked in some code for a simple action plugin.
> > > > > 
> > > > > [GitHub - jprante/elasticsearch-simple-action-plugin: A simple action plugin for Elasticsearch](https://github.com/jprante/elasticsearch-simple-action-plugin)
> > > > > 
> > > > > The plugin implements a simple "match\_all" search action, by reusing  
> > > > > much of  
> > > > > the code of the search action.
> > > > > 
> > > > > Best,
> > > > > 
> > > > > Jörg
> > > > > 
> > > > > On Thu, Sep 11, 2014 at 7:55 PM, Sandeep Ramesh Khanzode  
> > > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > > 
> > > > > > Thanks for bearing with me till now 🙂 Please provide one final  
> > > > > > input  
> > > > > > on  
> > > > > > this issue.
> > > > > > 
> > > > > > Is there any example for a custom search action? If not, can you  
> > > > > > please  
> > > > > > provide some details on how I can implement one?
> > > > > > 
> > > > > > Thanks,  
> > > > > > Sandeep
> > > > > > 
> > > > > > On Thu, Sep 11, 2014 at 4:53 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > > 
> > > > > > > You can not intercept the SearchResponse on the ES server itself.  
> > > > > > > Instead, you must implement your custom search action.
> > > > > > > 
> > > > > > > Jörg
> > > > > > > 
> > > > > > > On Thu, Sep 11, 2014 at 10:00 AM, Sandeep Ramesh Khanzode  
> > > > > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > > > > 
> > > > > > > > When you say, 'receive the SearchResponse', is that in the ES  
> > > > > > > > Server  
> > > > > > > > node or the TransportClient node that spawned the request? I would  
> > > > > > > > want to  
> > > > > > > > intercept the SearchResponse when created at the ES Server itself,  
> > > > > > > > since I  
> > > > > > > > want to send the subset of Response to another process on the same  
> > > > > > > > node, and  
> > > > > > > > it would not be very efficient to have the response sent back to  
> > > > > > > > the  
> > > > > > > > client  
> > > > > > > > node only to be sent back again.
> > > > > > > > 
> > > > > > > > Thanks,  
> > > > > > > > Sandeep
> > > > > > > > 
> > > > > > > > On Thu, Sep 11, 2014 at 12:43 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > > > > 
> > > > > > > > > You can receive the SearchResponse, process the response, and  
> > > > > > > > > return  
> > > > > > > > > the response with whatever format you want.
> > > > > > > > > 
> > > > > > > > > Jörg
> > > > > > > > > 
> > > > > > > > > On Wed, Sep 10, 2014 at 11:59 AM, Sandeep Ramesh Khanzode  
> > > > > > > > > [k.sandeep.r@gmail.com](mailto:k.sandeep.r@gmail.com) wrote:
> > > > > > > > > 
> > > > > > > > > > Hi Jorg,
> > > > > > > > > > 
> > > > > > > > > > Thanks for the links. I was checking the sources. There are  
> > > > > > > > > > relevant  
> > > > > > > > > > to my functional use case. But I will be using the  
> > > > > > > > > > TransportClient  
> > > > > > > > > > Java API,  
> > > > > > > > > > not the REST client.
> > > > > > > > > > 
> > > > > > > > > > Can you please tell me how I can find/modify these  
> > > > > > > > > > classes/sources  
> > > > > > > > > > to  
> > > > > > > > > > get the appropriate classes for inctercepting the Search  
> > > > > > > > > > Response  
> > > > > > > > > > when  
> > > > > > > > > > invoked from a TransportClient?
> > > > > > > > > > 
> > > > > > > > > > Thanks,  
> > > > > > > > > > Sandeep
> > > > > > > > > > 
> > > > > > > > > > On Wed, Aug 27, 2014 at 6:38 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
> > > > > > > > > > [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:
> > > > > > > > > > 
> > > > > > > > > > > Have a look at array-format or csv plugin, they are processing  
> > > > > > > > > > > the  
> > > > > > > > > > > SearchResponse to output it in another format:
> > > > > > > > > > > 
> > > > > > > > > > > [https://github.com/jprante/elasticsearch-arrayformat](https://github.com/jprante/elasticsearch-arrayformat)
> > > > > > > > > > > 
> > > > > > > > > > > [GitHub - jprante/elasticsearch-csv: CSV format for Elasticsearch REST search responses](https://github.com/jprante/elasticsearch-csv)
> > > > > > > > > > > 
> > > > > > > > > > > Jörg
> > > > > > > > > > > 
> > > > > > > > > > > On Wed, Aug 27, 2014 at 3:05 PM, 'Sandeep Ramesh Khanzode' via  
> > > > > > > > > > > elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:
> > > > > > > > > > > 
> > > > > > > > > > > > Hi,
> > > > > > > > > > > > 
> > > > > > > > > > > > Is there any action/module that I can extend/register/add so  
> > > > > > > > > > > > that  
> > > > > > > > > > > > I  
> > > > > > > > > > > > can intercept the SearchResponse on the server node before the  
> > > > > > > > > > > > response is  
> > > > > > > > > > > > sent back to the TransportClient on the calling box?
> > > > > > > > > > > > 
> > > > > > > > > > > > Thanks,  
> > > > > > > > > > > > Sandeep
> > > > > > > > > > > > 
> > > > > > > > > > > > --  
> > > > > > > > > > > > You received this message because you are subscribed to the  
> > > > > > > > > > > > Google  
> > > > > > > > > > > > Groups "elasticsearch" group.  
> > > > > > > > > > > > To unsubscribe from this group and stop receiving emails from  
> > > > > > > > > > > > it,  
> > > > > > > > > > > > send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > > > > > To view this discussion on the web visit
> > > > > > > > > > > > 
> > > > > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/559a5c68-4567-425f-9842-7f2fe6755095%40googlegroups.com).  
> > > > > > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > > > > > 
> > > > > > > > > > > --  
> > > > > > > > > > > You received this message because you are subscribed to a topic  
> > > > > > > > > > > in  
> > > > > > > > > > > the Google Groups "elasticsearch" group.  
> > > > > > > > > > > To unsubscribe from this topic, visit
> > > > > > > > > > > 
> > > > > > > > > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > > > > > > > > > To unsubscribe from this group and all its topics, send an  
> > > > > > > > > > > email  
> > > > > > > > > > > to  
> > > > > > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > > > > To view this discussion on the web visit
> > > > > > > > > > > 
> > > > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ\_%3D5RnyFqMP\_AX4744z6tdAp8cfLBi\_OqzLM23\_rqzw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGJ_%3D5RnyFqMP_AX4744z6tdAp8cfLBi_OqzLM23_rqzw%40mail.gmail.com).
> > > > > > > > > > > 
> > > > > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > > > > 
> > > > > > > > > > --  
> > > > > > > > > > You received this message because you are subscribed to the  
> > > > > > > > > > Google  
> > > > > > > > > > Groups "elasticsearch" group.  
> > > > > > > > > > To unsubscribe from this group and stop receiving emails from  
> > > > > > > > > > it,  
> > > > > > > > > > send  
> > > > > > > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > > > To view this discussion on the web visit
> > > > > > > > > > 
> > > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin\_aU4AXa%3DTVHQ\_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90bENin_aU4AXa%3DTVHQ_SyTTn-89Rev5vjj3%3DoDikwstkQ%40mail.gmail.com).
> > > > > > > > > > 
> > > > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > > > 
> > > > > > > > > --  
> > > > > > > > > You received this message because you are subscribed to a topic  
> > > > > > > > > in  
> > > > > > > > > the  
> > > > > > > > > Google Groups "elasticsearch" group.  
> > > > > > > > > To unsubscribe from this topic, visit
> > > > > > > > > 
> > > > > > > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > > > > > > > To unsubscribe from this group and all its topics, send an email  
> > > > > > > > > to  
> > > > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > > To view this discussion on the web visit
> > > > > > > > > 
> > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGWm8upDW9De7OvkM0cps%2BEyn3goo7Tgy3jyqJ8Jz5Khw%40mail.gmail.com).
> > > > > > > > > 
> > > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > You received this message because you are subscribed to the Google  
> > > > > > > > Groups "elasticsearch" group.  
> > > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > > send  
> > > > > > > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > > To view this discussion on the web visit
> > > > > > > > 
> > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi\_h7Buf1NLyk\_q3UOqLRMe0ZDsvQ\_MA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90aQiQO-cFzVb3vi_h7Buf1NLyk_q3UOqLRMe0ZDsvQ_MA%40mail.gmail.com).
> > > > > > > > 
> > > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to a topic in  
> > > > > > > the  
> > > > > > > Google Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this topic, visit
> > > > > > > 
> > > > > > > [https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/o6RZL4KwJVs/unsubscribe).  
> > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > To view this discussion on the web visit
> > > > > > > 
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEk0-VccZES3wNn8mEAbcuCJFV%3D8HKjw0udCAU-ysWXTA%40mail.gmail.com).
> > > > > > > 
> > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to the Google  
> > > > > > Groups  
> > > > > > "elasticsearch" group.  
> > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > send  
> > > > > > an  
> > > > > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > To view this discussion on the web visit
> > > > > > 
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZFshVUHHQM6fd0K9VCa14n0MDzUCxtu6zYV4kFciuBSQ%40mail.gmail.com).
> > > > > > 
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups  
> > > > > "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > send  
> > > > > an  
> > > > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > To view this discussion on the web visit
> > > > > 
> > > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH\_O75pf5\_ShaYy9rQy08NUYnvA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoENDoJG8Nkbd4%3Djn9kQH_O75pf5_ShaYy9rQy08NUYnvA%40mail.gmail.com).
> > > > > 
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups  
> > > > "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an  
> > > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > To view this discussion on the web visit
> > > > 
> > > > [https://groups.google.com/d/msgid/elasticsearch/CALuCJxhZ6t\_7hx30QoD30f3B3erP499JSHCTGxAQvJ518fFv8A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALuCJxhZ6t_7hx30QoD30f3B3erP499JSHCTGxAQvJ518fFv8A%40mail.gmail.com).  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an  
> > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit
> > > 
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEkFOeT4x7qi365MQ8Kz6f1YXWMc0-vV%2B0ur9PBYDAWSg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEkFOeT4x7qi365MQ8Kz6f1YXWMc0-vV%2B0ur9PBYDAWSg%40mail.gmail.com).
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CALuCJxgt25g1RHJuaVSZ37LLw-%3D%2BDAD0hY6gS8kCGh3zG\_4KUQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALuCJxgt25g1RHJuaVSZ37LLw-%3D%2BDAD0hY6gS8kCGh3zG_4KUQ%40mail.gmail.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHG8-iLuR90BWc9Lc1CLF20892bnOWV18P%3Df0ktY0tayA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHG8-iLuR90BWc9Lc1CLF20892bnOWV18P%3Df0ktY0tayA%40mail.gmail.com).
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALuCJxh1Xj7%3D\_oD%3Duwkgk%2BLwDumiKmtdg365%3D%2BX2e%2B0DHo1hww%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALuCJxh1Xj7%3D_oD%3Duwkgk%2BLwDumiKmtdg365%3D%2BX2e%2B0DHo1hww%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![moises\_acuna](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@moises\_acuna](https://discuss.elastic.co/u/moises_acuna)\
**Post date:** [July 22, 2016, 11:33am UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/14 "2016-07-22T11:33:45Z")

</div>

I know this is a 2 years old post but I'm trying to build something very similar to the example that jprante has in [https://github.com/jprante/elasticsearch-simple-action-plugin](https://github.com/jprante/elasticsearch-simple-action-plugin). I'm tyring to build the plugin for ES 2.3, the problem is that for the particular class:  
TransportSimpleAction ,I see that it's just a copy of the code from TransportSearchAction. I've tried to do the same in 2.3.x but i get a lot of errors regarding AbstractSearchAsyncAction , SearchQueryThenFetchAsyncAction and other same type AsyncActions . Because now the classes are package private. What i intend to do is just to intercept the incoming query at the server side and modify it to add an additional filter, i already have the code to modify the query, I'm just lost in the code to have it in a SearchAction plugin. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [July 23, 2016, 3:50pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/15 "2016-07-23T15:50:30Z")

</div>

Thanks for your interest in my plugin.

I have updated the demo plugin at [https://github.com/jprante/elasticsearch-simple-action-plugin](https://github.com/jprante/elasticsearch-simple-action-plugin) to Elasticsearch 2.3.4

The trick is to place your custom transport action implementation under the org.elasticsearch.action.search package to get package private access to the helper classes.

---

<div class="post-metadata">

**Author:** ![moises\_acuna](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@moises\_acuna](https://discuss.elastic.co/u/moises_acuna)\
**Post date:** [July 26, 2016, 1:12pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/16 "2016-07-26T13:12:04Z")

</div>

Hi Jörg,  
thanks for your response. I followed your changes and it works, but now i'm having an issue with the transport layer : when i send the request to the server it throws an IllegalStateException :

java.lang.IllegalStateException: Message not fully read (request) for requestId [2], action [indices:data/read/secure\_search], readerIndex [53] vs expected [171]; resetting  
at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:121)  
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)  
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)  
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)  
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)  
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)  
at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443)  
at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)  
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)  
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)  
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)  
at org.elasticsearch.common.netty.OpenChannelsHandler.handleUpstream(OpenChannelsHandler.java:75)  
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)  
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)  
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)  
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)  
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)  
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)  
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)  
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)  
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)  
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)  
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
at java.lang.Thread.run(Thread.java:745)

In with the client node in the unit tests it doesn't fail.  
I suspect that it's expecting far less bytes than what i'm sending to the message handler. But not sure how to debug it directly in the server.  
Thanks for any comment.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [July 26, 2016, 4:49pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/17 "2016-07-26T16:49:19Z")

</div>

> [@moises\_acuna](#):
>
> indices:data/read/secure\_search

That means that you have made coding or installation mistakes. It's not possible to comment on stack traces without the code that causes it. Can I see your code? What action is `indices:data/read/secure_search`?

> [@moises\_acuna](#):
>
> In with the client node in the unit tests it doesn't fail.

Why don't you use the code like in the unit test?

---

<div class="post-metadata">

**Author:** ![moises\_acuna](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@moises\_acuna](https://discuss.elastic.co/u/moises_acuna)\
**Post date:** [July 27, 2016, 9:50am UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/18 "2016-07-27T09:50:44Z")

</div>

Yes it seems that it didn't like my custom builder with encapsulated builder. I changed that anyways. Creating just the custom Action, and custom TransportAction. I'm using the same SearchRequest and SearchRequesBuilder as the return type for the newRequestBuilder method in my custom Action.  
My custom code is only on the custom TransportAction (actually right now it's commented out to avoid interference, and it's doing the same as the SearchTransportAction would do)  
The unit tests work (unit tests similar to what you have in your plugin). I install the plugin normally in the server (all is in the same version).

See the plugin class:  
[SecureRestSearchActionPlugin.java](https://gist.github.com/anonymous/f335a07923a4e50f21765c51fc612477)

The Custom Action (see that the action is using the OOTB SearchRequest and SearchRequestBuilder):

[SecureSearchAction.java](https://gist.github.com/anonymous/c5c9008e3ad17d0db0dca44ad11290a3)

And the custom TransportAction:

[TransportSecureSearchAction.java](https://gist.github.com/anonymous/9570dcabb2bcce0b0c6d7162018c4f29)

And then from a separate project and jvm i call the plugin using the TransportClient like:

[Calling code](https://gist.github.com/anonymous/7ccd596a571284af7ef20bd66789c77b)

When i run this latest i get the stack trace:

[Stacktrace 1](https://gist.github.com/anonymous/01dd376c5f96974ba1a6af0776d1f40c)

I've also installed your plugin and i have the same issue when calling from a remote TransportClient. (Actually i couldn't run your plugin without modifying SimpleRequest and implementing the interface IndicesRequest.Replaceable because ES was complaining that the indices where null)

I've read that you cannot use classes with private package access from different jars and class loader, not sure how to work around this. I couldn't extend from SearchTransportAction and just add my functionality overrinding the doExecute method, because the actionName variable is final and it can only be set from the protected construction in TransportAction. So if i do an extension i will be passing the SearchAction name instead of my custom name (and the custom code won't be called).

I also tried to encapsulate the SearchTransportAction in SecureTransportAction like:

[TransportSecureSearchAction\_encapsulated](https://gist.github.com/anonymous/7ff2f0169e66b90f5cf2cdfd81f385f0)

But then i get a similar stack trace from the code using the TransportClient :

[Stacktrace 2](https://gist.github.com/anonymous/1e18bc777ae260c56ca72ea031649cf7)

Any thoughts ?

---

<div class="post-metadata">

**Author:** ![adityasinghraghav](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@adityasinghraghav](https://discuss.elastic.co/u/adityasinghraghav)\
**Post date:** [August 9, 2016, 9:28am UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/19 "2016-08-09T09:28:23Z")

</div>

> [@jprante](#):
>
> The trick is to place your custom transport action implementation under the org.elasticsearch.action.search package to get package private access to the helper classes.

Hi Jörg,

I tried executing the simple action through a rest handler and keep getting the error  
`java.lang.IllegalAccessError: tried to access class org.elasticsearch.action.search.SearchQueryThenFetchAsyncAction from class org.elasticsearch.action.search.TransportSimpleAction`  
Any idea why this might be happening ?

---

<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 5, 2017, 10:29pm UTC](https://discuss.elastic.co/t/search-plugin-to-intercept-search-response/19494/20 "2017-07-05T22:29:08Z")

</div>


