# Restrict mapping so that only a single entity is inserted rather than an array

**URL:** <https://discuss.elastic.co/t/restrict-mapping-so-that-only-a-single-entity-is-inserted-rather-than-an-array/160478>\
**Category:** Elasticsearch\
**Created:** [December 12, 2018, 5:10am UTC](https://discuss.elastic.co/t/restrict-mapping-so-that-only-a-single-entity-is-inserted-rather-than-an-array/160478 "2018-12-12T05:10:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akg002](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@akg002](https://discuss.elastic.co/u/akg002)\
**Post date:** [December 12, 2018, 5:10am UTC](https://discuss.elastic.co/t/restrict-mapping-so-that-only-a-single-entity-is-inserted-rather-than-an-array/160478/1 "2018-12-12T05:10:17Z")

</div>

I have a field which strictly needs to be a single entity. But elastic accepts array as well. Can I restrict this behaviour such that only one element can be inserted.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [December 12, 2018, 12:39pm UTC](https://discuss.elastic.co/t/restrict-mapping-so-that-only-a-single-entity-is-inserted-rather-than-an-array/160478/2 "2018-12-12T12:39:10Z")

</div>

I do not think you can control that through mappings, so you would need to check client side before you index the data.

---

<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:** [January 9, 2019, 12:39pm UTC](https://discuss.elastic.co/t/restrict-mapping-so-that-only-a-single-entity-is-inserted-rather-than-an-array/160478/3 "2019-01-09T12:39:10Z")

</div>

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