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_core
After 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.
Related articles
Andrew Fletcher
•
04 Jun 2024
No results showing for your Solr instance - solr.service: Failed with result 'exit-code'
When Solr is displaying results on the site, first step is to log in the server and check its status● solr.service - LSB: Controls Apache Solr as a Service
Loaded: loaded (/etc/init.d/solr; generated)
Active: failed (Result: exit-code) since Wed 2024-04-17 23:22:52 UTC; 6h ago
...
Andrew Fletcher
•
17 Feb 2024
Drupal - Solr working through tm_X3b_en_body error
Having updated Solr, re-indexing wasn't working. The error in the logs wasDrupal\search_api_solr\SearchApiSolrException while indexing item entity:node/2386:en: Solr endpoint http://127.0.0.1:8983/ bad request (code: 400, body: Exception writing document id...
Andrew Fletcher
•
17 Feb 2024
Solr commands
On an Ubuntu 20.02 system with Nginx, you can utilize the following commands to handle Solr:To verify the status of the Solr servicesudo systemctl status solrTo restart the Solr servicesudo systemctl restart solrStart Solrsudo systemctl start solrStop Solrsudo systemctl stop solrEnable Solr (Start...