node-solr-client:更新文档并提交
node-solr-client: Updating Document and Commiting
我正在使用 node-solr-client 来处理 solr 查询。我已经根据 post 此处
编写了一个更新查询
Add and update data to Solr-4.3.0 using node module solr-client
我的数据是:
data = {
'type_s':'applicant',
'id': 5,
'state_id':{'set':565656},
};
我已启用自动提交为 true
client = solr.createClient();
client.autoCommit = true;
当我 运行 代码时,它会给我一个响应
{ responseHeader: { status: 0, QTime: 4 } }
意味着它已被添加到索引中。但是当我使用 solr admin 进行交叉检查时,我没有看到更新。现在,当我 运行 http://localhost:8983/solr/jobs/update?commit=true 并再次检查时,它在 solr admin 中可见。
终于成功了。
我只需要添加一个 softcommit()。这是代码。
data = {
'type_s':'applicant',
'id': 5,
'state_id':{'set':565656},
};
client = solr.createClient();
//client.autoCommit = true;
client.add(data, function(err, obj) {
if (err) {
console.log(err.stack);
} else {
client.softCommit();
}
});
});
刚刚好。我认为 autoCommit 选项不起作用或者我配置错误。
我正在使用 node-solr-client 来处理 solr 查询。我已经根据 post 此处
编写了一个更新查询Add and update data to Solr-4.3.0 using node module solr-client
我的数据是:
data = {
'type_s':'applicant',
'id': 5,
'state_id':{'set':565656},
};
我已启用自动提交为 true
client = solr.createClient();
client.autoCommit = true;
当我 运行 代码时,它会给我一个响应
{ responseHeader: { status: 0, QTime: 4 } }
意味着它已被添加到索引中。但是当我使用 solr admin 进行交叉检查时,我没有看到更新。现在,当我 运行 http://localhost:8983/solr/jobs/update?commit=true 并再次检查时,它在 solr admin 中可见。
终于成功了。
我只需要添加一个 softcommit()。这是代码。
data = {
'type_s':'applicant',
'id': 5,
'state_id':{'set':565656},
};
client = solr.createClient();
//client.autoCommit = true;
client.add(data, function(err, obj) {
if (err) {
console.log(err.stack);
} else {
client.softCommit();
}
});
});
刚刚好。我认为 autoCommit 选项不起作用或者我配置错误。