【问题标题】:how to delete all the records from solr index如何从solr索引中删除所有记录
【发布时间】:2014-07-31 06:00:20
【问题描述】:

我正在使用 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.ap ache.lucene.index.DocumentsWriter.delete 在 /var/www/library/Solarium/Core/Query/Result/Result.php 第 103 行

【问题讨论】:

  • 从源(数据库)中删除您的记录并在 solr 中重新索引该记录。
  • 记录在 solr 索引中如何从数据库中删除?我必须通过查询或从后端删除,插入删除时出现错误,仅搜索运行正常
  • 在索引时 solr 从哪里获取数据?有一些后端数据库。
  • 发布的答案请尝试提及的网址或询问我是否无法删除数据。
  • 你知道solr索引文件在数据库中的什么位置吗??我只是从 Dropbox 中获取文件和内容,将这些文件和内容插入到 solr 索引以进行全文搜索。我最后没有与数据库交互

标签: php solarium


【解决方案1】:

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

  1. 域:[PORT]/solr/#/collection1/query
  2. 将请求处理程序(qt)“/select”更改为“/delete”
  3. 对于删除所有记录 q = : 并按回车
  4. 对于删除特定 id id: 并按回车

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2011-03-30
      • 1970-01-01
      • 2017-12-23
      • 2012-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-01
      相关资源
      最近更新 更多