# How to detect when a new unique term has been inserted into an index on a specific field in a specific index in Elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-detect-when-a-new-unique-term-has-been-inserted-into-an-index-on-a-specific-field-in-a-specific-index-in-elasticsearch/58595>\
**Category:** Elasticsearch\
**Created:** [August 22, 2016, 4:41pm UTC](https://discuss.elastic.co/t/how-to-detect-when-a-new-unique-term-has-been-inserted-into-an-index-on-a-specific-field-in-a-specific-index-in-elasticsearch/58595 "2016-08-22T16:41:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TroyZuroske571](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/troyzuroske571/32/11525_2.png) [@TroyZuroske571](https://discuss.elastic.co/u/TroyZuroske571)\
**Post date:** [August 22, 2016, 4:41pm UTC](https://discuss.elastic.co/t/how-to-detect-when-a-new-unique-term-has-been-inserted-into-an-index-on-a-specific-field-in-a-specific-index-in-elasticsearch/58595/1 "2016-08-22T16:41:35Z")

</div>

I currently have a cron job that is looking at a field called "ex.set" and performs these tasks:

1. For every index, run a terms aggregation on the field "ex.set"
2. For every index, get every existing alias
3. For every unique term appearing in an index in "ex.set", if it does not have an existing alias, create a filtered alias

The job runs every ten minutes but most of the time does not find anything. Is there a way or a plugin (compatible with 2.3.x), that will automatically detect when a new unique term has been inserted into an index on a specific field in a specific index? And then if there is a unique item trigger the creation of a filtered alias on that index? Thank you in advance for any ideas or solutions.

---

<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, 10:26pm UTC](https://discuss.elastic.co/t/how-to-detect-when-a-new-unique-term-has-been-inserted-into-an-index-on-a-specific-field-in-a-specific-index-in-elasticsearch/58595/2 "2017-07-05T22:26:08Z")

</div>

Closed on July 5, 2017, 10:26pm UTC


