如何从solr索引中删除所有记录

时间:2014-07-31 06:00:20

标签: php solarium

我正在使用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();
}

但它在浏览器上给我以下错误:

  

致命错误:未捕获的异常&#39; Solarium \ Exception \ HttpException&#39;消息&#39; Solr HTTP错误:OK(500){&#34; responseHeader&#34;:{&#34; status&#34;:500,&#34; QTime&#34;:1},&# 34;错误&#34;:{&#34; trace&#34;:&#34; 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.Docu第103行/var/www/library/Solarium/Core/Query/Result/Result.php中的mentsWriter.delete

2 个答案:

答案 0 :(得分:0)

使用以下查询从solr中删除记录 -

  1. DOMAIN:[PORT] / solr /#/ collection1 / query
  2. 更改请求 - 处理程序(qt)&#34; / select&#34;去&#34; /删除&#34;
  3. 删除所有记录q = 并按Enter
  4. 删除特定ID id:并按Enter键

答案 1 :(得分:0)

如果你想删除所有索引,那么你也可以使用浏览器。 只需在浏览器中复制并粘贴以下链接即可。 http://localhost:8983/solr/update?stream.body=:&commit=true