# Elasticsearch Change Tracking plugin

**URL:** <https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821>\
**Category:** Elasticsearch\
**Created:** [February 27, 2012, 8:11pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821 "2012-02-27T20:11:56Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Peuss](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@Thomas\_Peuss](https://discuss.elastic.co/u/Thomas_Peuss)\
**Post date:** [February 27, 2012, 8:11pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/1 "2012-02-27T20:11:56Z")

</div>

Hi!

I have coded a small plugin for Elasticsearch that tracks changes to  
indices (inspired by [https://github.com/elasticsearch/elasticsearch/issues/1242](https://github.com/elasticsearch/elasticsearch/issues/1242))  
and makes that information available through a REST action.

You find the code here: [https://github.com/derryx/elasticsearch-changes-plugin](https://github.com/derryx/elasticsearch-changes-plugin)

Comments welcome  
Thomas

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 27, 2012, 10:51pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/2 "2012-02-27T22:51:13Z")

</div>

Heya,

That's a very interesting plugin ! Just like the couchdb \_changes API.  
Nice work ! I will try to play with it in the next days.

BTW, I just submit a Pull request [1] to add it in the plugins section [2] :

Just a few comments about the plugin. ZIP file is not available in your  
repository.  
You should add maven-assembly-plugin in your pom.xml to generate it.  
I added some comments in your repo about that [3].

HTH  
David.

[1] [https://github.com/elasticsearch/elasticsearch.github.com/pull/152](https://github.com/elasticsearch/elasticsearch.github.com/pull/152)  
[2] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/modules/plugins.html)  
[3]  
[Base structure · derryx/elasticsearch-changes-plugin@c7895ca · GitHub](https://github.com/derryx/elasticsearch-changes-plugin/commit/c7895ca976705d)  
f9a9a2a37927023d8a0b282ca5#commitcomment-1017313

> -----Message d'origine-----  
> De : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] De la part de Thomas Peuss  
> Envoyé : lundi 27 février 2012 21:12  
> À : elasticsearch  
> Objet : Elasticsearch Change Tracking plugin
> 
> Hi!
> 
> I have coded a small plugin for Elasticsearch that tracks changes to  
> indices (inspired by  
> [Changes API · Issue #1242 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1242))  
> and makes that information available through a REST action.
> 
> You find the code here: [https://github.com/derryx/elasticsearch-](https://github.com/derryx/elasticsearch-)  
> changes-plugin
> 
> Comments welcome  
> Thomas

---

<div class="post-metadata">

**Author:** ![Thomas\_Peuss](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@Thomas\_Peuss](https://discuss.elastic.co/u/Thomas_Peuss)\
**Post date:** [February 28, 2012, 7:23am UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/3 "2012-02-28T07:23:44Z")

</div>

Hi David!

On 27 Feb., 23:51, "David Pilato" [da...@pilato.fr](mailto:da...@pilato.fr) wrote:

> Heya,
> 
> That's a very interesting plugin ! Just like the couchdb \_changes API.  
> Nice work ! I will try to play with it in the next days.
> 
> BTW, I just submit a Pull request [1] to add it in the plugins section [2] :
> 
> Just a few comments about the plugin. ZIP file is not available in your  
> repository.  
> You should add maven-assembly-plugin in your pom.xml to generate it.  
> I added some comments in your repo about that [3].

I fix that tonight. Thanks for the hint.

CU  
Thomas

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 29, 2012, 1:51pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/4 "2012-02-29T13:51:02Z")

</div>

Heya, looks interesting. A had a quick look at the implementation, note that shards can move to a primary mode, and in this case, the tracking code won't happen. This is not how I would implement \_changes (in memory circular buffer), but I can see where it might fit certain scenarios.

On Tuesday, February 28, 2012 at 9:23 AM, Thomas Peuss wrote:

> Hi David!
> 
> On 27 Feb., 23:51, "David Pilato" \<[da...@pilato.fr](mailto:da...@pilato.fr) ([http://pilato.fr](http://pilato.fr))\> wrote:
> 
> > Heya,
> > 
> > That's a very interesting plugin ! Just like the couchdb \_changes API.  
> > Nice work ! I will try to play with it in the next days.
> > 
> > BTW, I just submit a Pull request [1] to add it in the plugins section [2] :
> > 
> > Just a few comments about the plugin. ZIP file is not available in your  
> > repository.  
> > You should add maven-assembly-plugin in your pom.xml to generate it.  
> > I added some comments in your repo about that [3].
> 
> I fix that tonight. Thanks for the hint.
> 
> CU  
> Thomas

---

<div class="post-metadata">

**Author:** ![Thomas\_Peuss](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@Thomas\_Peuss](https://discuss.elastic.co/u/Thomas_Peuss)\
**Post date:** [February 29, 2012, 3:48pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/5 "2012-02-29T15:48:23Z")

</div>

Hi Shay!

On 29 Feb., 14:51, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Heya, looks interesting. A had a quick look at the implementation, note that shards can move to a primary mode, and in this case, the tracking code won't happen. This is not how I would implement \_changes (in memory circular buffer), but I can see where it might fit certain scenarios.

First of all I know that this plugin is far from beeing finished. I  
just followed the mantra "release early". 😉

How would I notice that a shard moves to primary mode? Is there an  
event I can catch?

How would you do it? Suggestions are more then welcome!

This is my first deeper contact with the ES codebase and it is IMHO  
quite hard to understand how objects and services should be used (or  
meant to be used). One thing I do not understand is how I should  
contact the other nodes in the cluster to collect their changes.

Another functionality that is missing currently because I do not know  
how to do it is the following:  
The connection is kept open and all changes that are detected get  
pushed out to the client until the client closes the connection. I  
have found no notion of a "streaming" response.

CU  
Thomas

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 1, 2012, 12:27pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/6 "2012-03-01T12:27:10Z")

</div>

Hey,

You can check the shard routing changes to know when a shard changed its routing state. Check the different APIs implementations that go and operate on other nodes (for example, the count API). There is no support for pushing changes from the server to the client, \_changes would be implemented as a pull option.

Check the mailing list history, I wrote a bit on what and possibly how a changes API would work.

-shay.banon

On Wednesday, February 29, 2012 at 5:48 PM, Thomas Peuss wrote:

> Hi Shay!
> 
> On 29 Feb., 14:51, Shay Banon \<[kim...@gmail.com](mailto:kim...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> 
> > Heya, looks interesting. A had a quick look at the implementation, note that shards can move to a primary mode, and in this case, the tracking code won't happen. This is not how I would implement \_changes (in memory circular buffer), but I can see where it might fit certain scenarios.
> 
> First of all I know that this plugin is far from beeing finished. I  
> just followed the mantra "release early". 😉
> 
> How would I notice that a shard moves to primary mode? Is there an  
> event I can catch?
> 
> How would you do it? Suggestions are more then welcome!
> 
> This is my first deeper contact with the ES codebase and it is IMHO  
> quite hard to understand how objects and services should be used (or  
> meant to be used). One thing I do not understand is how I should  
> contact the other nodes in the cluster to collect their changes.
> 
> Another functionality that is missing currently because I do not know  
> how to do it is the following:  
> The connection is kept open and all changes that are detected get  
> pushed out to the client until the client closes the connection. I  
> have found no notion of a "streaming" response.
> 
> CU  
> Thomas

---

<div class="post-metadata">

**Author:** ![Thomas\_Peuss](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@Thomas\_Peuss](https://discuss.elastic.co/u/Thomas_Peuss)\
**Post date:** [March 1, 2012, 6:21pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/7 "2012-03-01T18:21:08Z")

</div>

Hi Shay!

2012/3/1 Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com):

> You can check the shard routing changes to know when a shard changed its  
> routing state. Check the different APIs implementations that go and operate

Is there something where I can register a handler for such changes? Or  
do you mean I should hook up with all shards and choose the right one  
when the request comes in?

> on other nodes (for example, the count API). There is no support for pushing  
> changes from the server to the client, \_changes would be implemented as a  
> pull option.

Sure. Client connects and the server keeps the connection open to push  
out new data as it comes available. So it is like a never-ending HTTP  
request.

> Check the mailing list history, I wrote a bit on what and possibly how a  
> changes API would work.

I do that!

CU  
Thomas

---

<div class="post-metadata">

**Author:** ![Thomas\_Peuss](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@Thomas\_Peuss](https://discuss.elastic.co/u/Thomas_Peuss)\
**Post date:** [March 2, 2012, 12:11pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/8 "2012-03-02T12:11:44Z")

</div>

Hi Shay!

Am Donnerstag, 1. März 2012 13:27:10 UTC+1 schrieb kimchy:

> Check the mailing list history, I wrote a bit on what and possibly how  
> a changes API would work.

You suggest to use the translog, right? That is of course a good source of  
information for the changes plugin. I keep that in mind.

CU  
Thomas

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 3, 2012, 10:01pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/9 "2012-03-03T22:01:44Z")

</div>

Yea, the main idea is to use the translog to keep track of changes. Its tricky though, since you somehow need to keep the translog around long enough for changes to be pulled, and manage the case of getting "all" changes, which require going (in order of operation) over the current index state, and then starting to pull the translog. Its a big feature in terms of work 🙂

On Friday, March 2, 2012 at 2:11 PM, Thomas Peuss wrote:

> Hi Shay!
> 
> Am Donnerstag, 1. März 2012 13:27:10 UTC+1 schrieb kimchy:
> 
> > Check the mailing list history, I wrote a bit on what and possibly how a changes API would work.
> 
> You suggest to use the translog, right? That is of course a good source of information for the changes plugin. I keep that in mind.
> 
> CU  
> Thomas

---

<div class="post-metadata">

**Author:** ![Thomas\_Peuss](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@Thomas\_Peuss](https://discuss.elastic.co/u/Thomas_Peuss)\
**Post date:** [March 5, 2012, 1:34pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/10 "2012-03-05T13:34:12Z")

</div>

Hi Shay!

Any chance to get notified when a shard changes routing from replica to  
primary and vice-versa?

CU  
Thomas

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 5, 2012, 2:53pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/11 "2012-03-05T14:53:37Z")

</div>

Yes, in 0.19, its part of the events you already register to (shard routing changed event).

On Monday, March 5, 2012 at 3:34 PM, Thomas Peuss wrote:

> Hi Shay!
> 
> Any chance to get notified when a shard changes routing from replica to primary and vice-versa?
> 
> CU  
> Thomas

---

<div class="post-metadata">

**Author:** ![Thomas\_Peuss](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@Thomas\_Peuss](https://discuss.elastic.co/u/Thomas_Peuss)\
**Post date:** [March 5, 2012, 3:27pm UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/12 "2012-03-05T15:27:09Z")

</div>

Hi Shay!

2012/3/5 Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com):

> Yes, in 0.19, its part of the events you already register to (shard routing  
> changed event).

Perfect.

Thank you  
Thomas

---

<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:37am UTC](https://discuss.elastic.co/t/elasticsearch-change-tracking-plugin/6821/13 "2017-07-06T03:37:19Z")

</div>


