A short guide to deleting a Solr document
After performing a major systems migration of our production environment to new hardware, we needed to perform a series of regression and integration tests to ensure all services, including Solr, were up-to-snuff. This included indexing a test document into Solr, which needed to be removed post-testing. Doing so can be done in two simple steps:
1. With the test document identifier (doc_id
), create an XML document with the following structure:
<delete>
<id>doc_id</id>
</delete>
and save it with the file name delete.xml
.
2. On the Solr server and in the .../solr/bin
directory, execute the following command where collection
is the Solr collection from which you want to delete the document and delete.xml
is the name of the XML file you created in step 1:
./post -c collection delete.xml
That's it.