# Query post processing

**URL:** <https://discuss.elastic.co/t/query-post-processing/19246>\
**Category:** Elasticsearch\
**Created:** [August 13, 2014, 9:03am UTC](https://discuss.elastic.co/t/query-post-processing/19246 "2014-08-13T09:03:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawel\_Rog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawel_rog/32/141223_2.png) [@Pawel\_Rog](https://discuss.elastic.co/u/Pawel_Rog)\
**Post date:** [August 13, 2014, 9:03am UTC](https://discuss.elastic.co/t/query-post-processing/19246/1 "2014-08-13T09:03:45Z")

</div>

Hi,  
I need an elasticsearch plugin which will build and add filter to each  
query passed to Elasticsearch. Above short scenario is showed:

1. Query string is sent to Elasticsearch
2. Query is parsed and prepared to execute on cluster
3. A filter is build based eg. on query, current time etc. and added to a  
query
4. Modified query is executed on Elasticsearch cluster

I'm wondering if I can do a plugin which will be triggered each time a  
query is being processed.

I know I can make a plugin with my own query parser but it also has  
drawback. Because all queries will have to contain something like:

{  
"query" : {  
"bool": {  
"must": [  
{  
"term": {  
"some\_field": "some\_term"  
}  
},  
{  
"CUSTOM\_QUERY\_TYPE": {  
"enabled": "true"  
}  
}  
]  
}  
}

But this looks not to be so convenient because client application will  
always have to extend the original query.

Is it possible to build plugin with query post processing and avoid  
building query parser or Rest action?

--  
Paweł Róg

--  
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/CAF9ZkbOU0FSNUXF%2B7DEyXPebVsVhYHhZ158YJZc0EVY%2BrpvEyg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbOU0FSNUXF%2B7DEyXPebVsVhYHhZ158YJZc0EVY%2BrpvEyg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:09am UTC](https://discuss.elastic.co/t/query-post-processing/19246/2 "2017-07-06T01:09:01Z")

</div>


