# Event Handling in Elasticsearch

**URL:** <https://discuss.elastic.co/t/event-handling-in-elasticsearch/6290>\
**Category:** Elasticsearch\
**Created:** [January 5, 2012, 4:57am UTC](https://discuss.elastic.co/t/event-handling-in-elasticsearch/6290 "2012-01-05T04:57:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [January 5, 2012, 4:57am UTC](https://discuss.elastic.co/t/event-handling-in-elasticsearch/6290/1 "2012-01-05T04:57:21Z")

</div>

```
          Hi there,
                       I want to know if the elasticsearch has 

```

implemented the event handling. Means, something similar to the triggers,  
for example, I want my scripting language to perform some action whenever  
some document of a particular type is pushed in the Elasticsearch Index.

---

<div class="post-metadata">

**Author:** ![Kartavya](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kartavya](https://discuss.elastic.co/u/Kartavya)\
**Post date:** [January 5, 2012, 5:46am UTC](https://discuss.elastic.co/t/event-handling-in-elasticsearch/6290/2 "2012-01-05T05:46:16Z")

</div>

Hi

Check percolate on index.

> <https://github.com/elastic/elasticsearch/issues/636>
>
> The index and bulk operation (for index bulk items) can now be automatically per…colated and return the queries they matched on. The \`percolate\` parameter can be passed to control which percolation queries should be used (it follows the query string format). For example:
> 
> Create an index we will work on:
> 
> \`\`\`
> curl -XPUT localhost:9200/test
> \`\`\`
> 
> Next, we will register a percolator query with a specific name called \`kuku\` against the \`test\` index:
> 
> \`\`\`
> curl -XPUT localhost:9200/\_percolator/test/kuku?refresh=true -d '{
> "color" : "blue",
> "query" : {
> "term" : {
> "field1" : "value1"
> }
> }
> }'
> \`\`\`
> 
> And now, we will index a doc, that has \`field1\` set to \`value1\`, and have it percolate:
> 
> \`\`\`
> curl -XPUT localhost:9200/test/type1/1?percolate=\* -d '{
> "field1" : "value1"
> }'
> \`\`\`
> 
> We will get this response:
> 
> \`\`\`
> {"ok":true,"\_index":"test","\_type":"type1","\_id":"1","\_version":2,"matches":\["kuku"\]}
> \`\`\`
> 
> Percolation query filtering is simple to do, lets register another query, for \`bubu\`, but now with \`color\` set to \`green\` and matching on \`field2\`:
> 
> \`\`\`
> curl -XPUT localhost:9200/\_percolator/test/bubu?refresh=true -d '{
> "color" : "green",
> "query" : {
> "term" : {
> "field2" : "value2"
> }
> }
> }'
> \`\`\`
> 
> Now, we can control which queries can be executed, for example:
> 
> \`\`\`
> curl -XPUT localhost:9200/test/type1/1?percolate=\* -d '{
> "field1" : "value1",
> "field2" : "value2"
> }'
> 
> curl -XPUT localhost:9200/test/type1/1?percolate=color:green -d '{
> "field1" : "value1",
> "field2" : "value2"
> }'
> 
> curl -XPUT localhost:9200/test/type1/1?percolate=color:blue -d '{
> "field1" : "value1",
> "field2" : "value2"
> }'
> \`\`\`
> \## Implementation Details
> 
> Percolation on index operation is done while optimizing the distributed nature of elasticsearch. Once the index operation is done on the primary shard, it is sent to all the replicas, and while the operation is done on the replicas, the percolation is executed on the node hosting the primary shard. Also, the parsing operation done on the primary shard is reused for the percolation operation.

Regards,  
Pulkit Agrawal

On Thu, Jan 5, 2012 at 10:27 AM, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in) wrote:

> ```
> Hi there,
> I want to know if the elasticsearch has
> 
> ```
> 
> implemented the event handling. Means, something similar to the triggers,  
> for example, I want my scripting language to perform some action whenever  
> some document of a particular type is pushed in the Elasticsearch Index.

---

<div class="post-metadata">

**Author:** ![karmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karmi/32/44951_2.png) [@karmi](https://discuss.elastic.co/u/karmi)\
**Post date:** [January 7, 2012, 9:50am UTC](https://discuss.elastic.co/t/event-handling-in-elasticsearch/6290/3 "2012-01-07T09:50:07Z")

</div>

Yes, \_percolate is the thing you're after, as Pulkit suggests. Check  
out [http://karmi.github.com/tire/#section-Percolation](http://karmi.github.com/tire/#section-Percolation) for an example  
how to do it with Ruby. Other clients will have similar support.

On Jan 5, 5:57 am, Narinder Kaur [narinder.k...@izap.in](mailto:narinder.k...@izap.in) wrote:

> ```
> Hi there,
> I want to know if the elasticsearch has
> 
> ```
> 
> implemented the event handling. Means, something similar to the triggers,  
> for example, I want my scripting language to perform some action whenever  
> some document of a particular type is pushed in the Elasticsearch Index.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:43am UTC](https://discuss.elastic.co/t/event-handling-in-elasticsearch/6290/4 "2017-07-06T03:43:35Z")

</div>


