I have an elasticsearch document in the following format. I need to partially update the "x" field and add python python to it.
{ "_index": "gdata34", "_type": "gdat", "_id": "328091-72341-118", "_version": 1, "_score": 1, "_source": { "d": { "Thursday": { "s": "" }, "Email": { "s": "" }, "Country": { "s": "US" }, }, "x": { "Geo": { "s": "45.335428,-118.057133", "g": [ -118.057133 , 45.335428 ] } }, } }
I tried the following code to update:
from elasticsearch import Elasticsearch, exceptions import pprint elasticsearch = Elasticsearch() doc = elasticsearch.get(index='gdata34', doc_type='gdat', id='328091-72341-7') elasticsearch.update(index='gdata34', doc_type='gdat', id='328091-72341-7', body={"script":"ctx._source.x += y", "params":{"y":"z"} } ) elasticsearch.indices.refresh(index='gdata34') new_doc = elasticsearch.get(index='gdata34', doc_type='gdat', id='328091-72341-7')
I get this error:
elasticsearch.exceptions.RequestError: TransportError(400, u'ElasticsearchIllegalArgumentException[failed to execute script]; nested: ScriptException[dynamic scripting for [groovy] disabled]; ')
What is the correct way to partially upgrade in elasticsearch using python?
source share