[英]how to delete all the records from solr index
我正在使用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();
}
但这在浏览器中给了我以下错误:
致命错误:消息为“ Solr HTTP错误”的未捕获异常“ Solarium \\ Exception \\ HttpException”:确定(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:280) )\\ n \\ tat org.apach 第103行的/var/www/library/Solarium/Core/Query/Result/Result.php中的e.lucene.index.DocumentsWriter.delete
使用以下查询从solr中删除您的记录-
如果您想删除所有索引,那么您也可以使用浏览器。 只需将以下链接复制并粘贴到浏览器中。 http://localhost:8983/solr/update?stream.body=:&commit=true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.