ES update API with script via Python client


(Patrick Lam) #1

Hi,

I'm trying to use the Update API via the Python client on ES 2.1.1 and I'm having trouble.

es.index(index='boston', doc_type='stem_map', id=111, body={'word': 'showing', 'counter': 29})
es.get(index='boston', doc_type='stem_map', id=111)

{'_id': '111',
 '_index': 'boston',
 '_source': {'counter': 29, 'word': 'showing'},
 '_type': 'stem_map',
 '_version': 1,
 'found': True}
upscript = {
    'script': {
        'inline': 'ctx._source.counter += count', 
        'params': {
            'count': 100
        }
    }
}

Then I tried both of the following:

es.update(index='boston', doc_type='stem_map', id=111, body=upscript)
es.update(index='boston', doc_type='stem_map', id=111, script=upscript)

I'm getting the following error:

RequestError: TransportError(400, 'illegal_argument_exception', '[John Walker][127.0.0.1:9300][indices:data/write/update[s]]')

Does anybody know what I'm doing wrong?


(system) #2