# NodeClient and org.elasticsearch.cluster.ClusterStateListener

**URL:** <https://discuss.elastic.co/t/nodeclient-and-org-elasticsearch-cluster-clusterstatelistener/40582>\
**Category:** Elasticsearch\
**Created:** [January 31, 2016, 11:16am UTC](https://discuss.elastic.co/t/nodeclient-and-org-elasticsearch-cluster-clusterstatelistener/40582 "2016-01-31T11:16:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbrutman](https://avatars.discourse-cdn.com/v4/letter/b/e480ec/32.png) [@bbrutman](https://discuss.elastic.co/u/bbrutman)\
**Post date:** [January 31, 2016, 11:16am UTC](https://discuss.elastic.co/t/nodeclient-and-org-elasticsearch-cluster-clusterstatelistener/40582/1 "2016-01-31T11:16:29Z")

</div>

Hi,

We are doing a rolling index and would like to know on the NodeClient that the new index has been added. Is it possible to listen to an event that would indicate a new index creation?

Thanks!

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [January 31, 2016, 7:39pm UTC](https://discuss.elastic.co/t/nodeclient-and-org-elasticsearch-cluster-clusterstatelistener/40582/2 "2016-01-31T19:39:02Z")

</div>

Yes, you can create a `ClusterStateObserver` with a `ChangePredicate` that encodes that the indices have changed. For the `apply` override that accepts two cluster states you have to compare `ClusterState#metaData#indices` and for the `apply` override that accepts a `ClusterChangedEvent` you can just inspect `ClusterChangedEvent#indicesCreated`.

---

<div class="post-metadata">

**Author:** ![bbrutman](https://avatars.discourse-cdn.com/v4/letter/b/e480ec/32.png) [@bbrutman](https://discuss.elastic.co/u/bbrutman)\
**Post date:** [February 3, 2016, 8:16am UTC](https://discuss.elastic.co/t/nodeclient-and-org-elasticsearch-cluster-clusterstatelistener/40582/3 "2016-02-03T08:16:15Z")

</div>

Thanks for the prompt and useful reply!

---

<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, 11:19pm UTC](https://discuss.elastic.co/t/nodeclient-and-org-elasticsearch-cluster-clusterstatelistener/40582/4 "2017-07-05T23:19:19Z")

</div>


