工作流程:
remote source -> import to mysql -> select all outdated records in mysql -> send request to SOLR with all outdated records ids -> solr delete by multiple ids > push new records to Solr.
按多个 ID 删除文档的正确查询语法是什么?
我尝试:
id:(1 OR 2 OR 3)...
id:(1 AND 2 AND 3)
在 PHP 中:
$query = sprintf('id:(%s)', implode(' AND ', $toDelete));
$solrUrl = sprintf('http://%s:%s/%s/%s', $this->solr['host'], $this->solr['port'], $this->solr['path'], $action);
$docs = [
'delete' => ['query' => $query]
];
$http = new Client();
$http->post($solrUrl, json_encode($docs),['type' => 'json', 'timeout' => 30]);
最佳答案
线索是简单地将删除请求重写为按查询删除,然后将所有要删除的 id 作为简单的 OR 查询提交。不用说,这已经足够快并且解决了我们的问题。
总结一下;将按查询删除语句编写为:
id:(123123 或 13371337 或 42424242 ..)
关于php - Solr,按多个id批量删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52424153/