【问题标题】:Update solr collection using solr-client使用 solr-client 更新 solr 集合
【发布时间】:2013-12-10 12:19:14
【问题描述】:

我正在使用 nodejs 的 solr-client 模块来查询我的 solr 集合。

现在我正在尝试使用 solr-client 在我的后端代码中添加和更新集合。

我已经尝试http://lbdremy.github.io/solr-node-client/code/add.js.html 成功地将数据添加到集合中。但我不知道如何更新记录。

我尝试过使用这种方法(所有方法都可以在这里找到:http://lbdremy.github.io/solr-node-client/code/solr.js.html);

    /**
     * Send an update command to the Solr server with the given `data` stringified in the body.
     *
     * @param {Object} data - data sent to the Solr server
     * @param {Function} callback(err,obj) - a function executed when the Solr server responds or an error occurs
     * @param {Error} callback().err
     * @param {Object} callback().obj - JSON response sent by the Solr server deserialized
     *
     * @return {Client}
     * @api private
     */

    Client.prototype.update = function (data, callback) {
        var self = this;
        this.options.json = JSON.stringify(data);
        this.options.fullPath = [this.options.path, this.options.core, 'update/json?commit=' + this.autoCommit + '&wt=json']
            .filter(function (element) {
                if (element) {
                    return true;
                }
                return false;
            })
            .join('/');
        updateRequest(this.options, callback);


return self;
}

但是这个方法怎么知道要更新哪些记录呢?它是否在数据参数中搜索 pk,当它与集合中的 pk 匹配时,它会更新吗?它是否需要额外的提交?

【问题讨论】:

  • 我也陷入了这个问题。解决方案在这里通过 add 方法。

标签: node.js solr


【解决方案1】:

但是这个方法怎么知道要更新哪些记录呢?见下文

它是否在 data 参数中搜索 pk,当它与集合中的 pk 匹配时,它会更新吗? - 是的

它是否需要额外的提交? - 是的

从技术上讲,您可以使用 INSERT 和 UPDATE。在 SOLR 中是一样的

【讨论】:

猜你喜欢
  • 2017-09-16
  • 1970-01-01
  • 1970-01-01
  • 2016-03-22
  • 1970-01-01
  • 2016-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多