Andrew Fletcher published: 16 February 2024 2 minutes read
Cleaning out or clearing data in Solr can be done in a few different ways, depending on your specific requirements.
Delete All Documents
You can use the Solr Admin interface or send a DELETE request to remove all documents from a Solr core.
Solr Admin Interface:
- Open your web browser and navigate to the Solr Admin interface, typically at http://your_solr_server:8983/solr.
- Select the core you want to clear.
- Click on the "Query" menu.
- In the "q" field, enter *:* to match all documents.
- Click on the "Execute Query" button.
- Click on the "Delete Query" button to remove all documents.
Using CURL (Command Line):
curl http://your_solr_server:8983/solr/your_core/update?commit=true -d '<delete><query>*:*</query></delete>'
Delete by Query
If you want to remove documents based on specific criteria, you can use a delete query.
Solr Admin Interface
- Open the Solr Admin interface
- Select the core you want to clear
- Click on the "Query" menu
- Enter your delete query in the "q" field
- Click on the "Execute Query" button
- Click on the "Delete Query" button to remove matching documents.
Using CURL
curl http://your_solr_server:8983/solr/your_core/update?commit=true -d '<delete><query>your_query_here</query></delete>'
Delete Core and Recreate
If you want to remove all data and start fresh, you can delete the entire Solr core and recreate it.
Solr Admin Interface
- Open the Solr Admin interface
- Click on the "Core Admin" tab
- Select the core you want to delete
- Click on the "Unload" button to delete the core
- Create a new core with the same name if needed.
Using CURL
curl http://your_solr_server:8983/solr/admin/cores?action=UNLOAD&core=your_coreAfter unloading the core, you can create a new core using the Core Admin API or by modifying your Solr configuration.
Remember to replace your_solr_server and your_core with the appropriate values for your Solr setup.