[英]How to update the document on solr 6.0?
I am using solr 6.0
version. 我正在使用
solr 6.0
版本。
This is my data 这是我的资料
{
"id" : "14",
"solrid" : "solr|school|14",
"name" : "test update solr 14",
"status" : "pending",
"state" : "Andhra Pradesh",
"board" : "CISCE",
"updated" : "2016-05-26T02:24:25Z",
"pincode" : "0"
}
I want to update the data on document as per id. 我想根据ID更新文档中的数据。 example i want to change the name
例如我想更改名称
$doc = $update->createDocument();
$doc["id"] =$id;
$doc["name"]="school";
$update->addDocument($doc);
$update->addCommit();
$client->update($update);
This code is correct? 此代码正确吗? Or i want to use other flow.
或者我想使用其他流程。 PHP Solarium code.
PHP日光浴室代码。
Yes, basically the flow is correct. 是的,基本上流程是正确的。 You can always check the solarim examples gist at https://gist.github.com/basdenooijer/894286 .
您可以随时在https://gist.github.com/basdenooijer/894286中查看solarim示例要点。
Alternatively you can do something like this: 或者,您可以执行以下操作:
$update = $client->createUpdate();
$document = $update->createDocument();
$document->setKey('id', $id);
foreach ($data as $field => $value) {
if ($field == 'id') {
continue;
}
$document->setField($field, $value, null, 'set');
}
$update->addDocument($document, true, 1500);
$result = $client->update($update);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.