# Can we limit number of unique values per fields?

**URL:** <https://discuss.elastic.co/t/can-we-limit-number-of-unique-values-per-fields/234662>\
**Category:** Elasticsearch\
**Created:** [May 28, 2020, 6:14am UTC](https://discuss.elastic.co/t/can-we-limit-number-of-unique-values-per-fields/234662 "2020-05-28T06:14:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nishan\_Maharjan1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nishan_maharjan1/32/69251_2.png) [@Nishan\_Maharjan1](https://discuss.elastic.co/u/Nishan_Maharjan1)\
**Post date:** [May 28, 2020, 6:14am UTC](https://discuss.elastic.co/t/can-we-limit-number-of-unique-values-per-fields/234662/1 "2020-05-28T06:14:55Z")

</div>

The company i work for has had some query regarding this matter. They want to check if elasticsearch is capable of limiting the number of unique values allowed in a field.

EX: the fields "source\_ip" may only have three unique values, say, 192.168.0.1, 192.168.0.2 and 192.168.0.3.

I searched through the elasitcsearch documentation whether the indices settings, or field mapping supports this, but i could find such possibility.

Is there any way this can be done ?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 28, 2020, 6:22am UTC](https://discuss.elastic.co/t/can-we-limit-number-of-unique-values-per-fields/234662/2 "2020-05-28T06:22:18Z")

</div>

Welcome to our community! 😃

No there's not, you'd need to do it during ingestion. You could use an ingest node for it, assuming you don't even want the data - [https://www.elastic.co/guide/en/elasticsearch/reference/current/drop-processor.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/drop-processor.html)

---

<div class="post-metadata">

**Author:** ![Nishan\_Maharjan1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nishan_maharjan1/32/69251_2.png) [@Nishan\_Maharjan1](https://discuss.elastic.co/u/Nishan_Maharjan1)\
**Post date:** [May 28, 2020, 8:09am UTC](https://discuss.elastic.co/t/can-we-limit-number-of-unique-values-per-fields/234662/3 "2020-05-28T08:09:14Z")

</div>

Thanks mate, I have not looked into injection. I will check if this solves our need.

---

<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:** [June 25, 2020, 8:09am UTC](https://discuss.elastic.co/t/can-we-limit-number-of-unique-values-per-fields/234662/4 "2020-06-25T08:09:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
