Node.js 使用solr客户端更新solr集合
我正在使用nodejs的solr客户端模块来查询我的solr集合 现在,我正尝试使用solr客户端在我的后端代码中添加和更新集合 我已成功地尝试将数据添加到集合中。但我不知道如何更新记录 我尝试过使用这个方法(所有方法都可以在这里找到:)Node.js 使用solr客户端更新solr集合,node.js,solr,Node.js,Solr,我正在使用nodejs的solr客户端模块来查询我的solr集合 现在,我正尝试使用solr客户端在我的后端代码中添加和更新集合 我已成功地尝试将数据添加到集合中。但我不知道如何更新记录 我尝试过使用这个方法(所有方法都可以在这里找到:) 但是这个方法如何知道要更新哪些记录呢?它是否在数据参数中搜索pk,当它与集合中的pk匹配时,它会得到更新?它需要额外的提交吗?但是这个方法如何知道要更新哪些记录呢?见下文 它是否在数据参数中搜索pk,并且当它与集合中的pk匹配时,它会得到更新对 它是否需要额外
但是这个方法如何知道要更新哪些记录呢?它是否在数据参数中搜索pk,当它与集合中的pk匹配时,它会得到更新?它需要额外的提交吗?但是这个方法如何知道要更新哪些记录呢?见下文 它是否在数据参数中搜索pk,并且当它与集合中的pk匹配时,它会得到更新对 它是否需要额外提交对
从技术上讲,u可以使用插入和更新。它们在SOLR中是相同的你能看看为什么add有效,而update无效吗?我也被这个问题困住了。这里的解决方案是通过add方法实现的。
/**
* 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;
}