Reputation: 93
I am trying to update a field in ES record and it errors out.
ES JSON document
{
"_index": "Barroz",
"_type": "_doc",
"_id": "pGcGz3gBRea5RG",
"_version": 67,
"_score": 1,
"_source": {
"tid": "f90a48519ceeb9e43f21898363b59",
"taep": "test.treat",
"cluster": "Barroz.GuardianofDGamasTreasure",
"state": "Failure",
"notes": "Looks good"
}
}
What I am trying:
elastic_client = Elasticsearch(["http://localhost:9200"])
query_body = {"_source": { "state": "Success" } }
elastic_client.update(index="Barroz", doc_type="_doc", id=pGcGz3gBRea5RG,
body=query_body)
I am getting the below error:
status_code, error_message, additional_info
elasticsearch.exceptions.RequestError: RequestError(400, 'x_content_parse_exception', 'Unknown key for a VALUE_STRING in [state].')
Please let me know whats the mistake.
Upvotes: 1
Views: 1672
Reputation: 2461
It is mentioned in ElasticSearch 7.17
docs to wrap the body in the doc
key to perform partial updates to the document.
{
"doc": {
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
}
Upvotes: 0
Reputation: 217254
The update
endpoint accepts the following body, i.e. simply replace _source
by doc
:
query_body = {"doc": { "state": "Success" } }
Upvotes: 4