Elasticsearch _bulk 更新问题给出 VersionConflictEngineException 消息
Elasticsearch _bulk update issue giving VersionConflictEngineException message
我在我的一个项目中使用 elasticsearch。我在更新记录时遇到问题。我收到的错误消息是:-
{ _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 } } ]
当您开始查询一条记录时,它会响应该记录,包括该记录的版本。当你想更新它时,但在它之前,它已经被另一个人更新过,数据库中的记录版本比客户端认为的要高。
这可能是因为某些操作仍在队列中,因此您获得了未处理的记录(因此版本较低)。发生这种情况时,请尝试 https://www.elastic.co/guide/en/elasticsearch/reference/1.6/indices-refresh.html:
curl -XPOST 'http://localhost:9200/{your_index}/_refresh'
然后再次调用你的方法
我在我的一个项目中使用 elasticsearch。我在更新记录时遇到问题。我收到的错误消息是:-
{ _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 } } ]
当您开始查询一条记录时,它会响应该记录,包括该记录的版本。当你想更新它时,但在它之前,它已经被另一个人更新过,数据库中的记录版本比客户端认为的要高。 这可能是因为某些操作仍在队列中,因此您获得了未处理的记录(因此版本较低)。发生这种情况时,请尝试 https://www.elastic.co/guide/en/elasticsearch/reference/1.6/indices-refresh.html:
curl -XPOST 'http://localhost:9200/{your_index}/_refresh'
然后再次调用你的方法