How to delete a file attachment from the apachesolr index 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-&gt;fid, 'file');
apachesolr_remove_entity($env_id, $entity_type, $entity_id);
drupal_set_message('Deleting '.$file-&gt;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?
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=
&lt;delete&gt;&lt;query&gt;id:298253&lt;/query&gt;&lt;/delete&gt;&amp;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=
&lt;delete&gt;&lt;query&gt;id:298253&lt;/query&gt;
&lt;query&gt;entitytype:BlogEntry&lt;/query&gt;&lt;/delete&gt;&amp;commit=true