0

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.apache.lucene.index.DocumentsWriter.delete in /var/www/library/Solarium/Core/Query/Result/Result.php on line 103

Kevin
  • 41,694
  • 12
  • 53
  • 70
john
  • 567
  • 8
  • 23
  • Delete your record from the source (database) and re-index that record in solr. – GKS Jul 31 '14 at 07:57
  • records are in solr index how can i delete from database ?? either i have to delete by query or from back end , i am getting errors to inserting deleting only searching is running correctly – john Jul 31 '14 at 08:19
  • from where solr is getting data while indexing? There is some backend database. – GKS Jul 31 '14 at 08:24
  • Posted answer please try to mentioned url or ask to me if you will unable to delete data. – GKS Jul 31 '14 at 08:26
  • do you know where is solr index files in database ?? i am just get the files and content from dropbox inserting these to solr index to for full text search .no interaction with database at my end – john Jul 31 '14 at 08:28
  • http://{host}:{port}/solr/#/~cores/autocomplete It will show you where solr is installed... – GKS Jul 31 '14 at 08:32
  • i have to remove the data folder?? – john Jul 31 '14 at 09:28
  • then you will lost all your data stored in that folder.. – GKS Jul 31 '14 at 09:29
  • so please suggest what to do i am getting the error Uncaught exception 'Solarium\Exception\HttpException' with message 'Solr HTTP error: OK (500) {"responseHeader":{"status":500,"QTime":2},"error":{"msg":"Exception writing document id 1 to the index; possible analysis error.","trace":"org.apache.solr.common.SolrException: Exception writing document id 1 to the index; possible analysis error.\n\tat when i am indexing the data to solr – john Jul 31 '14 at 09:32
  • It would be great if you can share solr url and unique key=>value of item which you want to delete. – GKS Jul 31 '14 at 09:35
  • http://23.253.246.179:8983/solr i want to delete all the records – john Jul 31 '14 at 09:38
  • follow steps which i have mentioned in answer. Update url as you given – GKS Jul 31 '14 at 09:57

2 Answers2

0

Use following query to delete your records from solr -

  1. DOMAIN:[PORT]/solr/#/collection1/query
  2. Change Request-Handler (qt) "/select" to "/delete"
  3. For delete all records q = : and press enter
  4. For delete specific id id: and press enter
GKS
  • 106
  • 5
0

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

bittu
  • 337
  • 2
  • 13