# Need help to update document fields in python

**URL:** <https://discuss.elastic.co/t/need-help-to-update-document-fields-in-python/16431>\
**Category:** Elasticsearch\
**Created:** [March 18, 2014, 3:40pm UTC](https://discuss.elastic.co/t/need-help-to-update-document-fields-in-python/16431 "2014-03-18T15:40:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PAULINE\_BONNEAU](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@PAULINE\_BONNEAU](https://discuss.elastic.co/u/PAULINE_BONNEAU)\
**Post date:** [March 18, 2014, 3:40pm UTC](https://discuss.elastic.co/t/need-help-to-update-document-fields-in-python/16431/1 "2014-03-18T15:40:47Z")

</div>

Hi all,

I'm new here and have a problem with a query in python. I hope someone can  
help me ,please.

My problem is :

I have some documents in an index. I would like to update some document  
fields in the index but I don't know how. If someone can help me, please  
explain me how I can do that. I work in python with pyes.

If my problem is not clear, I can explain more.

Sorry if my writing in english is not very clear 🙂

Paulyne

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5688e05c-d4f0-4492-bc3f-c68d22a9d085%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5688e05c-d4f0-4492-bc3f-c68d22a9d085%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Honza\_Kral](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/honza_kral/32/876_2.png) [@Honza\_Kral](https://discuss.elastic.co/u/Honza_Kral)\
**Post date:** [March 18, 2014, 3:47pm UTC](https://discuss.elastic.co/t/need-help-to-update-document-fields-in-python/16431/2 "2014-03-18T15:47:28Z")

</div>

Hi Paulyne,

unfortunately with elasticsearch you need to update your documents  
one-by-one using the Update API, I am not too familiar with pyes, but  
it exposes the api as a method it seems:  
[http://pyes.readthedocs.org/en/latest/references/pyes.es.html?highlight=update#pyes.es.ES.update](http://pyes.readthedocs.org/en/latest/references/pyes.es.html?highlight=update#pyes.es.ES.update)

alternatively you can just use the official python client that exposes  
the api without any change from the curl:  
[http://elasticsearch-py.readthedocs.org/en/master/api.html#elasticsearch.Elasticsearch.update](http://elasticsearch-py.readthedocs.org/en/master/api.html#elasticsearch.Elasticsearch.update)

Another alternative is just to index new version of the same document  
(same index, type and id) using any api or tool you used in the first  
place, that will overwrite the document in elasticsearch.

Hope this helps,  
Honza

On Tue, Mar 18, 2014 at 4:40 PM, PAULINE BONNEAU  
[pauline.bonneau.33@gmail.com](mailto:pauline.bonneau.33@gmail.com) wrote:

> Hi all,
> 
> I'm new here and have a problem with a query in python. I hope someone can  
> help me ,please.
> 
> My problem is :
> 
> I have some documents in an index. I would like to update some document  
> fields in the index but I don't know how. If someone can help me, please  
> explain me how I can do that. I work in python with pyes.
> 
> If my problem is not clear, I can explain more.
> 
> Sorry if my writing in english is not very clear 🙂
> 
> Paulyne
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/5688e05c-d4f0-4492-bc3f-c68d22a9d085%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5688e05c-d4f0-4492-bc3f-c68d22a9d085%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CABfdDiqb1D4PFwYAZFdRoUw-Za5mu%2BgXZcTT1n4wp%3DoYnkj7Nw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABfdDiqb1D4PFwYAZFdRoUw-Za5mu%2BgXZcTT1n4wp%3DoYnkj7Nw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![PAULINE\_BONNEAU](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@PAULINE\_BONNEAU](https://discuss.elastic.co/u/PAULINE_BONNEAU)\
**Post date:** [March 18, 2014, 4:02pm UTC](https://discuss.elastic.co/t/need-help-to-update-document-fields-in-python/16431/3 "2014-03-18T16:02:47Z")

</div>

Hi Honza,

Thanks for your help. I will try this now.

Paulyne

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b27d5190-78b6-4ca6-9c04-ed230d14eecb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b27d5190-78b6-4ca6-9c04-ed230d14eecb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![PAULINE\_BONNEAU](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@PAULINE\_BONNEAU](https://discuss.elastic.co/u/PAULINE_BONNEAU)\
**Post date:** [March 18, 2014, 5:06pm UTC](https://discuss.elastic.co/t/need-help-to-update-document-fields-in-python/16431/4 "2014-03-18T17:06:36Z")

</div>

I'm sorry but I have just one more problem. I don't know what I must put in  
the _document_ parameter in the update function :

update(_index_, _doc\_type_, _id_, _script=None_, _lang='mvel'_,  
_params=None_, _document=None_, _upsert=None_, _model=None_, _bulk=False_,  
_querystring\_args=None_, _retry\_on\_conflict=None_, _routing=None_,  
_doc\_as\_upsert=None_)

I think this parameter permits me to update some fields of this document  
but I don't know how to do that.  
Thanks

Paulyne

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/dbe1e0f0-284e-4f95-912b-9ee30dd42105%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/dbe1e0f0-284e-4f95-912b-9ee30dd42105%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Honza\_Kral](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/honza_kral/32/876_2.png) [@Honza\_Kral](https://discuss.elastic.co/u/Honza_Kral)\
**Post date:** [March 18, 2014, 7:17pm UTC](https://discuss.elastic.co/t/need-help-to-update-document-fields-in-python/16431/5 "2014-03-18T19:17:35Z")

</div>

The document you will put in will be merged with the document in  
elasticsearch.

Honza  
On Mar 18, 2014 6:06 PM, "PAULINE BONNEAU" [pauline.bonneau.33@gmail.com](mailto:pauline.bonneau.33@gmail.com)  
wrote:

> I'm sorry but I have just one more problem. I don't know what I must put  
> in the _document_ parameter in the update function :
> 
> update(_index_, _doc\_type_, _id_, _script=None_, _lang='mvel'_,  
> _params=None_, _document=None_, _upsert=None_, _model=None_, _bulk=False_,  
> _querystring\_args=None_, _retry\_on\_conflict=None_, _routing=None_,  
> _doc\_as\_upsert=None_)
> 
> I think this parameter permits me to update some fields of this document  
> but I don't know how to do that.  
> Thanks
> 
> Paulyne
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/dbe1e0f0-284e-4f95-912b-9ee30dd42105%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/dbe1e0f0-284e-4f95-912b-9ee30dd42105%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/dbe1e0f0-284e-4f95-912b-9ee30dd42105%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/dbe1e0f0-284e-4f95-912b-9ee30dd42105%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CABfdDioy9bzb--TmbGK1sMtV37uL9iWhc177LPjeJfEEfH5R1g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABfdDioy9bzb--TmbGK1sMtV37uL9iWhc177LPjeJfEEfH5R1g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:42am UTC](https://discuss.elastic.co/t/need-help-to-update-document-fields-in-python/16431/6 "2017-07-06T01:42:27Z")

</div>


