我正在使用 solr 进行全文搜索。
我是 solr 的新手,并试图通过 php solarium 客户端从 solr 索引中删除记录我正在使用以下代码删除记录:
include_once("vendor/autoload.php");
$client = new Solarium\Client();
if(isset($_POST['delete']))
{
$update = $client->createUpdate();
// add the delete query and a commit command to the update query
$update->addDeleteQuery('*:*');
$update->addCommit();
// this executes the query and returns the result
$result = $client->update($update);
echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();
}
但它在浏览器上给了我以下错误:
致命错误:未捕获的异常 'Solarium\Exception\HttpException' 带有消息 'Solr HTTP 错误:OK (500) {"responseHeader":{"status":500,"QTime":1},"error":{"trace" :"java.lang.NullPointerException\n\tat org.apache.lucene.search.BooleanClause.hashCode(BooleanClause.java:99)\n\tat java.util.AbstractList.hashCode(AbstractList.java:542)\n\ tat org.apache.lucene.search.BooleanQuery.hashCode(BooleanQuery.java:520)\n\tat java.util.HashMap.put(HashMap.java:389)\n\tat org.apache.lucene.index.BufferedUpdates .addQuery(BufferedUpdates.java:152)\n\tat org.apache.lucene.index.DocumentsWriterDeleteQueue$QueryArrayNode.apply(DocumentsWriterDeleteQueue.java:365)\n\tat org.apache.lucene.index.DocumentsWriterDeleteQueue$DeleteSlice.apply (DocumentsWriterDeleteQueue.java:280)\n\tat org.apache.lucene。index.DocumentsWriterDeleteQueue.tryApplyGlobalSlice(DocumentsWriterDeleteQueue.java:200)\n\tat org.apache.lucene.index.DocumentsWriterDeleteQueue.addDelete(DocumentsWriterDeleteQueue.java:107)\n\tat org.apache.lucene.index.DocumentsWriter.delete in /var/www/library/Solarium/Core/Query/Result/Result.php 在第 103 行