Elasticsearch _bulk更新问题给出VersionConflictEngineException消息

我在我的一个项目中使用elasticsearch。 我在更新logging时遇到问题。 我得到的错误信息是: –

{ _index: 'makes', _type: 'make', _id: '55b8cdbae36236490d00002a', status: 409, error: 'VersionConflictEngineException[[makes][0] [make][55b8cdbae36236490d00002a]: version conflict, current [168], provided [167]]' } 

使用ES散装API。 我的应用程序在node.js.

让我分享我的代码:

 var conditions = []; conditions.push({ update: { _index: config.elasticSearch.index, _type: config.elasticSearch.type, _id: id } }); conditions.push({ doc: { published: true } }); client.bulk({ body: conditions }, function(err, resp) { console.log(resp); console.log(resp.items[0].update); return res.send({success: true, message: "Shows updated successful"}) }); 

以下是条件数组的值:

 [ { update: { _index: 'makes', _type: 'make', _id: '55b8cdbae36236490d00002a' } }, { doc: { published: true } } ] 

当你开始查询一个logging时,它的logging包括该logging的版本的响应。 当你想更新它,但在它之前,它已经被另一个更新,数据库中的logging比客户想象的更高版本。 这可能会发生,因为有些操作仍然在队列中,所以你得到未处理的logging(因此更低的版本)。 发生这种情况时,请尝试https://www.elastic.co/guide/en/elasticsearch/reference/1.6/indices-refresh.html

 curl -XPOST 'http://localhost:9200/{your_index}/_refresh' 

然后再次调用你的方法