# How to return the modified document with bulk update

**URL:** <https://discuss.elastic.co/t/how-to-return-the-modified-document-with-bulk-update/240758>\
**Category:** Elasticsearch\
**Created:** [July 10, 2020, 8:09pm UTC](https://discuss.elastic.co/t/how-to-return-the-modified-document-with-bulk-update/240758 "2020-07-10T20:09:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)\
**Post date:** [July 10, 2020, 8:09pm UTC](https://discuss.elastic.co/t/how-to-return-the-modified-document-with-bulk-update/240758/1 "2020-07-10T20:09:03Z")

</div>

Previously (not sure about the versions, but I can't see errors with 6.8) I could use the bulk API to update a doc and to get back the modified document with (snippet from actual code using the Python Elastic client):

```python
bulkops.append({'_op_type': 'update',
                                '_index': elastic_index,
                                '_type': elastic_doctype,
                                '_id': oid,
                                'retry_on_conflict': 8,
                                'fields': '_source',
                                'doc': changes})
res = helpers.parallel_bulk(self.es, bulkops,
                                            raise_on_exception=False,
                                            raise_on_error=False)

```

however with 7.8 this gives the following error:

```auto
'error': "RequestError(400, 'x_content_parse_exception', '[1:2] "
              "[UpdateRequest] unknown field [fields]')",
'exception': RequestError(400, 'x_content_parse_exception', {'error': {'root_cause': [{'type': 'x_content_parse_exception', 'reason': '[1:2] [UpdateRequest] unknown field [fields]'}], 'type': 'x_content_parse_exception', 'reason': '[1:2] [UpdateRequest] unknown field [fields]'}, 'status': 400}),

```

According to the docs here:  
[https://www.elastic.co/guide/en/elasticsearch/reference/7.8/docs-update.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.8/docs-update.html)  
the `_source` could control what should it return, but I've got no luck with that either.

So my question is: how could I get back the modified document with a bulk update?

---

<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:** [August 7, 2020, 8:09pm UTC](https://discuss.elastic.co/t/how-to-return-the-modified-document-with-bulk-update/240758/2 "2020-08-07T20:09:10Z")

</div>

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