简体   繁体   English

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

[英]how to delete all the records from solr index

I am using solr to full text search. 我正在使用solr进行全文搜索。

I am new to solr and trying to delete the records from the solr index by php solarium client I am using the following code to delete the records: 我是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();
}

But it is giving me the following error on browser: 但这在浏览器中给了我以下错误:

Fatal error: Uncaught exception 'Solarium\\Exception\\HttpException' with message 'Solr HTTP error: 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.apach 致命错误:消息为“ 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 e.lucene.index.DocumentsWriter.delete in /var/www/library/Solarium/Core/Query/Result/Result.php on line 103 第103行的/var/www/library/Solarium/Core/Query/Result/Result.php中的e.lucene.index.DocumentsWriter.delete

Use following query to delete your records from solr - 使用以下查询从solr中删除您的记录-

  1. DOMAIN:[PORT]/solr/#/collection1/query 域:[PORT] / solr /#/ collection1 / query
  2. Change Request-Handler (qt) "/select" to "/delete" 将请求处理程序(qt)“ /选择”更改为“ /删除”
  3. For delete all records q = : and press enter 对于删除所有记录Q =:然后按回车键
  4. For delete specific id id: and press enter 对于删除特定的id id :,然后按Enter

if you want to delete all the index then u can use the browser also. 如果您想删除所有索引,那么您也可以使用浏览器。 Just copy and paste the following link in the browser. 只需将以下链接复制并粘贴到浏览器中。 http://localhost:8983/solr/update?stream.body=:&commit=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM