你能帮帮我吗。我必须通过Solr文档的唯一标识符来更新它。比方说,我有一个这样的文档:
{
"text": "qwe",
"id": "01a3aa6db06d39e8",
"_version_": 1471599607983112200
}我想更新字段"phrase",所以我将以下内容发布到127.0.0.1:8983/solr/ update /?commit=true:
[
{
"id" : "01a3aa6db06d39e8",
"text" : {"set":"qwe. updated"}
}
]Solr表示400 Bad Request,并返回以下内容:
{
"responseHeader":
{
"status":400,"QTime":0},
"error":{"msg":"Document contains multiple values for uniqueKey field: id=[01a3aa6db06d39e8, 0000000000000000]","code":400}
}
}如何正确更新包含唯一键的文档?
发布于 2016-03-17 15:44:10
试试这个吧。
{"id":"01a3aa6db06d39e8","text":"hello world , this is an update"}如果您希望将文本作为像mongodb那样多维数组,那么solr中不能满足这种要求,但是有一些方法可以实现,有点混乱。
如果您使用脚本来更新文档,并且我认为您使用的是一个循环,请在while循环中包含提交和实例化,就像PHP中的这样:
while($row = mysqli_fetch_assoc($result))
{
$client = new SolrClient($options);
$doc = new SolrInputDocument();
$doc->addField('id', $row['id']);
$doc->addField('date', '2015-06-01T00:00:0.0Z');
$doc->addField('name', $row['name']);
$updateResponse = $client->addDocument($doc);
}
$client->commit();https://stackoverflow.com/questions/25826278
复制相似问题