# Re: Only update a single field in existing document

**URL:** https://discuss.elastic.co/t/re-only-update-a-single-field-in-existing-document/4067
**Category:** Elasticsearch
**Created:** [March 9, 2011, 7:06pm UTC](https://discuss.elastic.co/t/re-only-update-a-single-field-in-existing-document/4067 "2011-03-09T19:06:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [March 9, 2011, 7:06pm UTC](https://discuss.elastic.co/t/re-only-update-a-single-field-in-existing-document/4067/1 "2011-03-09T19:06:02Z")

</div>

If you are going to do that, make sure you use the versioning support in order not to need to refresh. Get the doc, change it, and index it back with the version received from the get operation. A conflict will be raised if it has been updated in the meantime (or since the last refresh ran).  
On Wednesday, March 9, 2011 at 8:38 PM, Rob Faraj wrote:

> Thanks for the info Clint.
> 
> I don't have a ton of fields for each document, so your advise of  
> retrieving from ES and then reindexing is what I'm going to try first.
> 
> On Mar 2, 12:37 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:
> 
> > Hi Rob
> > 
> > On Wed, 2011-03-02 at 09:32 -0800, Rob Faraj wrote:
> > 
> > > I did some searching and found a couple threads that were similar, but  
> > > not exactly what I'm trying to do. I would like to update one field of  
> > > an existing document and reindex this new value of the field while  
> > > keeping all existing fields the same. Is this possible?
> > 
> > I'm afraid you have to reindex the whole document. That said, you  
> > already have the full source for the document stored in ES, so you could  
> > retrieve that, update the single field, then reindex it.
> > 
> > You might also want to look at parent/child relationships as that was  
> > introduced specifically to get around having to reindex whole documents.
> > 
> > > BTW: I posted this originally through Nabble and it sat in a Pending  
> > > status of \>15hrs. Apologies if it's frowned upon to repost through  
> > > google groups.
> > 
> > It happens quite a lot - no worries 🙂
> > 
> > clint

---

<div class="post-metadata">

### Author: ![canal](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@canal](https://discuss.elastic.co/u/canal)
#### Post date: [March 10, 2011, 1:56am UTC](https://discuss.elastic.co/t/re-only-update-a-single-field-in-existing-document/4067/2 "2011-03-10T01:56:06Z")

</div>

isn't a parent-child solution a better option?

I will be trying a use case which requires updating a single field - it is more  
like a content management use case, not one for search engine but I love to see  
how ES can handle this without using a separate system:

- I would like to support full text search with use access permissions:  
not all documents are accessible by all users; some users can only access  
some documents.  
documents here are binary documents, Office or PDF for example.

So if I would use parent-child to support this, is it correct that:

- create a parent document for the binary file
- create the child document with user-permissions

yet to understand how exactly the parent-child works and how I can exec full  
text search yet filtering based on the permissions in the child doc...  
thanks,  
canal

* * *

From: Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)  
To: [users@elasticsearch.com](mailto:users@elasticsearch.com)  
Sent: Thu, March 10, 2011 3:06:02 AM  
Subject: Re: Only update a single field in existing document

If you are going to do that, make sure you use the versioning support in order  
not to need to refresh. Get the doc, change it, and index it back with the  
version received from the get operation. A conflict will be raised if it has  
been updated in the meantime (or since the last refresh ran).

On Wednesday, March 9, 2011 at 8:38 PM, Rob Faraj wrote:  
Thanks for the info Clint.

> I don't have a ton of fields for each document, so your advise of  
> retrieving from ES and then reindexing is what I'm going to try first.
> 
> On Mar 2, 12:37 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:
> 
> Hi Rob
> 
> > On Wed, 2011-03-02 at 09:32 -0800, Rob Faraj wrote:
> > 
> > I did some searching and found a couple threads that were similar, but
> > 
> > > not exactly what I'm trying to do. I would like to update one field of  
> > > an existing document and reindex this new value of the field while  
> > > keeping all existing fields the same. Is this possible?
> 
> I'm afraid you have to reindex the whole document. That said, you  
> already have the full source for the document stored in ES, so you could  
> retrieve that, update the single field, then reindex it.
> 
> You might also want to look at parent/child relationships as that was  
> introduced specifically to get around having to reindex whole documents.
> 
> BTW: I posted this originally through Nabble and it sat in a Pending
> 
> > status of \>15hrs. Apologies if it's frowned upon to repost through  
> > google groups.

It happens quite a lot - no worries 🙂

clint

---

<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 6, 2017, 4:10am UTC](https://discuss.elastic.co/t/re-only-update-a-single-field-in-existing-document/4067/3 "2017-07-06T04:10:22Z")

</div>


