Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get back modified fields from a bulk update? #1346

Closed
bra-fsn opened this issue Aug 11, 2020 · 1 comment
Closed

How to get back modified fields from a bulk update? #1346

bra-fsn opened this issue Aug 11, 2020 · 1 comment

Comments

@bra-fsn
Copy link

bra-fsn commented Aug 11, 2020

Elasticsearch version (bin/elasticsearch --version): 7.7.0

elasticsearch-py version (elasticsearch.__versionstr__): 7.5.1

Description of the problem including expected versus actual behavior:
With previous elasticsearch version, this code snippet has worked:

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

But after upgrading elasticsearch to 7.x, this fails with:

'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}),

What I'm trying to accomplish here is to get back the modified document with the bulk updates.

With curl, I can do the following:
curl -s -H "Content-Type: application/x-ndjson" -XPOST 'localhost:9200/_bulk?pretty&_source=true' --data-binary "@requests"

So I think the question is: how to specify query parameters with the helpers.bulk API? As it can be seen from the doc and the above curl call, elasticsearch itself supports this.

Steps to reproduce:
Execute the above code on a 7.x elasticsearch.

@sethmlarson
Copy link
Contributor

This was implemented in 7.10 via #1387

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants