Skip to main content

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:

  1. Open your web browser and navigate to the Solr Admin interface, typically at http://your_solr_server:8983/solr.
  2. Select the core you want to clear.
  3. Click on the "Query" menu.
  4. In the "q" field, enter *:* to match all documents.
  5. Click on the "Execute Query" button.
  6. 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

  1. Open the Solr Admin interface
  2. Select the core you want to clear
  3. Click on the "Query" menu
  4. Enter your delete query in the "q" field
  5. Click on the "Execute Query" button
  6. 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

  1. Open the Solr Admin interface
  2. Click on the "Core Admin" tab
  3. Select the core you want to delete
  4. Click on the "Unload" button to delete the core
  5. 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 Fletcher17 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 Fletcher17 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...