簡體   English   中英

如何從Solr索引中刪除所有記錄

[英]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中刪除您的記錄-

  1. 域:[PORT] / solr /#/ collection1 / query
  2. 將請求處理程序(qt)“ /選擇”更改為“ /刪除”
  3. 對於刪除所有記錄Q =:然后按回車鍵
  4. 對於刪除特定的id id :,然后按Enter

如果您想刪除所有索引,那么您也可以使用瀏覽器。 只需將以下鏈接復制並粘貼到瀏覽器中。 http://localhost:8983/solr/update?stream.body=:&commit=true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM