【问题标题】:Elasticsearch _bulk update issue giving VersionConflictEngineException messageElasticsearch _bulk 更新问题给出 VersionConflictEngineException 消息
【发布时间】:2015-10-21 08:53:09
【问题描述】:

我在我的一个项目中使用弹性搜索。我在更新记录时遇到问题。我收到的错误消息是:-

{ _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 } } ]

【问题讨论】:

    标签: node.js elasticsearch-plugin elasticsearch


    【解决方案1】:

    当您开始查询一条记录时,它对记录的响应包括该记录的版本。当您想更新它,但在它之前已经被另一个更新时,数据库中的记录的版本比客户认为的要高。 这可能是因为某些操作仍在队列中,因此您获得了未处理的记录(因此是较低版本)。发生这种情况时,请尝试https://www.elastic.co/guide/en/elasticsearch/reference/1.6/indices-refresh.html

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

    然后再次调用你的方法

    【讨论】:

    • 有些问题似乎无法解决,除非您以前遇到过它们……这花了我几个小时:p
    • 是的,你是对的。你拯救了我的一天。这是我们的项目发布,这个问题来了。
    • 然后去修复版本的其余部分 ;-)
    • 我愿意。我们有什么方法可以在 make.report 中添加超时。我正在使用 makeapi-client 从 Elasticsearch 创建更新和删除记录。?
    • 好的,没问题。感谢您的大力帮助 :) 我接受了(y)
    猜你喜欢
    • 2021-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    • 2015-12-07
    • 2011-01-29
    相关资源
    最近更新 更多