2

我正在使用 node-solr-client 来处理 solr 查询。我已经按照这里的帖子写了一个更新查询

使用节点模块 solr-client 向 Solr-4.3.0 添加和更新数据

我的数据是:

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 中可见。

4

1 回答 1

4

最后我让它工作了。

我只需要添加一个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 选项不起作用或者我配置错误。

于 2015-12-17T04:06:47.147 回答