Faster Learning Tutorials

The Solr delete command syntax and examples

This command will delete a core in standalone mode or a collection in SolrCloud mode.
  1. About - understand the purpose of the delete command.
  2. Syntax - see solr delete command usage from the command line.
  3. Options - view 3 options used with the solr delete command.
  4. Examples - review several common examples including additional help.
by Paul Alan Davis, CFA, October 12, 2017
Updated: July 16, 2018
Here we focus on the command line using a Linux-based operating system, however many of the same commands work for macOS. There are slight differences for Windows.

Outline Back Next

~/ home  / tech  / solr  / reference  / solr delete

The solr delete command


In the current environment, developers of search applications have choices. First, cloud-based services from Google Custom Search or Amazon CloudSearch, among others, provide offerings suited for website search. In the enterprise search area, or where customization is more important including advanced analytics, the Apache Lucene libraries used by Apache Solr and Elasticsearch have gained traction.

In the case of Apache Solr, it is typical for new users to set up a test environment in standalone mode before advancing to a distributed search production environment using SolrCloud. During this evaluation and testing it is common to create cores (in standalone mode) and collections (in SolrCloud mode). After testing data sets it is common to clean up and delete the test cases for which the solr delete command is helpful.

Apache Solr Reference

1. About the solr delete command

The solr delete command will delete cores and collections on the Solr server as specified. It is also used to delete associated configuration files.

The solr delete command is one of 12 commands within the main solr script.

The solr delete command itself has 3 options, also known as parameters.

2. Syntax for the solr delete command

The syntax for running solr delete is as follows.

$ bin/solr delete [-c name] [-deleteConfig true|false] [-p port]

The list of 3 options including default values are described in the table below.

This syntax assumes your current working directory is the $SOLR_HOME directory for Solr, which for version 7 would be ~/solr-7.0.0/ in standalone mode for a local installation. When running in a production environment the directory locations may differ.

So the path to the location of the solr script is: ~/solr-7.0.0/bin/solr. Alternatively, the solr script can be run using the convention ./solr from within the bin directory.

When using Windows, the solr script is called using solr.cmd.

3. Options for the solr delete command

For the solr delete command the -c <name> option is required while the other options (parameters) are optional.

Syntax Purpose Default
bin/solr delete with the required -c <name> option specified Delete the named Solr core or collection with default options. Solr will delete the specified core and its associated configuration files at the first port number found.
-c <name> Delete the Solr core or collection <name>. -c <name> is required
-deleteConfig <port> Delete the Solr core or collection and the configuration files provided with -c <name> from ZooKeeper. When used, this option requires the boolean true or false. If the configuration files are used by another collection they will not be deleted, regardlesss of whether true or false was selected. true
-p <port> Delete the Solr core or collection on the -p <port> provided. This is useful when there are multiple standalone Solr instances running. Solr will search for and delete the Solr instance on the first port found.

4. Examples of the solr delete command

Example 1 - Delete a Solr core

The following command will delete the Solr core named mycore and its associated configuration files.

$ bin/solr delete -c mycore
Example 2 - Delete a Solr core on port 8984

The following command will delete the Solr core named mycore on port 8984.

$ bin/solr delete -c mycore -p 8984
Example 3 - Delete a Solr collection and save non-default configurations

The following command will delete the Solr collection named mycollection from ZooKeeper and leave the non-default configurations saved under the directory, hypothetically called myconfigs. This is useful if the configurations saved in the directory myconfigs are to be shared by another collection.

$ bin/solr delete -c mycollection -deleteConfig false
Example 4 - Print additional help on the solr delete command

From the command line you can access additional help on the solr delete command by appending -help after the command.

$ bin/solr delete -help

Other Related Solr Content

FactorPad offers Apache Solr Search content in both tutorials and reference.

What's Next?

If you prefer video tutorials for your Apache Solr learning check out our growing YouTube Channel. Subscribe here.

  • To see the outline of Solr reference material, click Outline.
  • To learn the create collection command in Solr, click Back.
  • To learn how to find your Solr version number, click Next.

Outline Back Next

~/ home  / tech  / solr  / reference  / solr delete

solr reference
apache solr
solr search
website search
enterprise search
apache lucene
lucene reference
solr examples
solr commands
solr syntax
solr help
solr delete core
solr delete collection
google site search
solr settings
solr configuration
solr delete man page