0

My file attachments are indexed using apachesolr attachments 7.x-1.x-dev. I have a custom module that physically deletes a file using file_delete(), but file still remains in Apachesolr index even after re-indexing. The only way to remove from search results is to delete the index then reindex.

I tried this to no avail:

// Remove file from apachesolr index
$env_id = apachesolr_default_environment();
$entity_type = 'file';
$entity_id = apachesolr_document_id($file->fid, 'file');
apachesolr_remove_entity($env_id, $entity_type, $entity_id);
drupal_set_message('Deleting '.$file->uri.' from private attachments.');
file_delete($file);

The file is physically removed, but not removed from index.

Any suggestions on how to remove file from apachesolr attachments index/search results after it is deleted?

1 Answer 1

0

From Dileno blog:

If you simply want to delete documents from your Solr index by using the web interface, here's a code snippet that lets you do so:

http://localhost:8983/solr/update?stream.body=
<delete><query>id:298253</query></delete>&commit=true

This lets you delete documents where the id field matches 298253.

If you want to delete items that matches more than one field, just add another query:

http://localhost:8983/solr/update?stream.body=
<delete><query>id:298253</query>
<query>entitytype:BlogEntry</query></delete>&commit=true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.