# Restrict the fields from being updated

**URL:** <https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264>\
**Category:** Elasticsearch\
**Created:** [May 6, 2021, 9:18am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264 "2021-05-06T09:18:49Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepti](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Deepti](https://discuss.elastic.co/u/Deepti)\
**Post date:** [May 6, 2021, 9:18am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/1 "2021-05-06T09:18:49Z")

</div>

Hi ,

Is there a way to restrict the updation of a particular field while indexing a document.  
For example I have a field 'name' which is of type text and I index a document , next time I try to change this 'name' either it should throw me an erro or should not accept the new value.

---

<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 10, 2021, 12:47am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/2 "2021-05-10T00:47:57Z")

</div>

> [@Deepti](#):
>
> next time I try to change this 'name' either it should throw me an erro or should not accept the new value

Change it how?  
If you are talking about changing it from a text field to numeric, Elasticsearch will not allow that.

---

<div class="post-metadata">

**Author:** ![Deepti](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Deepti](https://discuss.elastic.co/u/Deepti)\
**Post date:** [May 10, 2021, 4:04am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/3 "2021-05-10T04:04:59Z")

</div>

Hi @warkolm  
If suppose I try to index a document the 2nd time and this time the name field is changed from "Tom" to "Bob" , I want to prevent this change , restrict a field from being updated.

---

<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 10, 2021, 4:06am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/4 "2021-05-10T04:06:35Z")

</div>

Ok, you want to stop a document from being updated entirely?

---

<div class="post-metadata">

**Author:** ![Deepti](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Deepti](https://discuss.elastic.co/u/Deepti)\
**Post date:** [May 10, 2021, 5:29am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/5 "2021-05-10T05:29:15Z")

</div>

@warkolm  
Not entire document but few fields in the document

---

<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 10, 2021, 5:41am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/6 "2021-05-10T05:41:10Z")

</div>

The only way to do that is via field level security.

---

<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:** [May 10, 2021, 5:47am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/7 "2021-05-10T05:47:30Z")

</div>

As far as I know enabling field level security gives a read only view of the index so I do not think it is a solution. This is not possible in Elasticsearch so is something you would control in your code when indexing or updating the data.

---

<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 10, 2021, 5:49am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/8 "2021-05-10T05:49:38Z")

</div>

Ah yes, you are right. It doesn't cover writes.

---

<div class="post-metadata">

**Author:** ![Deepti](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Deepti](https://discuss.elastic.co/u/Deepti)\
**Post date:** [May 10, 2021, 6:21am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/9 "2021-05-10T06:21:19Z")

</div>

Thank you @Christian_Dahlqvist

---

<div class="post-metadata">

**Author:** ![Deepti](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Deepti](https://discuss.elastic.co/u/Deepti)\
**Post date:** [May 10, 2021, 6:21am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/10 "2021-05-10T06:21:35Z")

</div>

Thank you @warkolm

---

<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 7, 2021, 6:22am UTC](https://discuss.elastic.co/t/restrict-the-fields-from-being-updated/272264/11 "2021-06-07T06:22:15Z")

</div>

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