插入新文档(如果尚不存在)或更新(将计数器增加 1)已存在文档的最优雅方法是什么?
这个:
res = elasticsearch.update(
index='stories-test',
doc_type='news',
id=1,
body={
"doc":
{
"author": "me",
"visits": 1
},
'doc_as_upsert': True
},
script={
"inline": "ctx._source.visits += visit",
"params": {
"visit": 1
}
}
)
通过以下错误:
RequestError: TransportError(400, u'action_request_validation_exception', u"Validation Failed: 1: can't provide both script and doc;")