NodeClient and org.elasticsearch.cluster.ClusterStateListener


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?


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.

Thanks for the prompt and useful reply!