I am using solr to full text search.
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:
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 e.lucene.index.DocumentsWriter.delete in /var/www/library/Solarium/Core/Query/Result/Result.php on line 103
Use following query to delete your records from solr -
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.