FactorPad
Build a Better Process

The Solr create Command Syntax and Examples

This command is one of three Solr commands used to create cores and collections at the command line. It interprets which mode to start in: standalone (core) or SolrCloud (collection).
  1. About - understand the purpose of the create command.
  2. Syntax - see solr create command usage from the command line.
  3. Options - view 6 options used with the solr create command.
  4. Examples - review several common examples including additional help.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
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 Tip Next

/ factorpad.com / tech / solr / reference / solr-create.html


An ad-free and cookie-free website.


The Solr create Command

Beginner

Many people test Apache Solr search during their evaluation of options for enterprise search and website search. Two common options exist. First, offerings provided by Google Custom Search or Amazon CloudSearch offer a managed search option. Others evaluate building their own applications using Apache Solr and Elasticsearch.

Any comprehensive review requires building a test environment which is normally performed in one-server standalone mode. Next, as search volumes increase it is important to review distributed search offerings and in Apache Solr that sits in SolrCloud mode.

Tests in Solr require building test data sets and configurations for managing the search application. Here with solr create you can create either a core for standalone mode in a testing environment. This command can also be used to create a collection for SolrCloud mode.

Apache Solr Reference

1. About the solr create command

The solr create command will automatically detect the mode when it creates either the core or collection. If you know which one you want to create you can jump straight to the solr create_core for standalone mode, or solr create_collection for SolrCloud mode. Alternatively, you can stick with solr create.

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

The solr create command itself has 6 options, also known as parameters.

2. Syntax for the solr create command

The syntax for running solr create is as follows.

$ bin/solr create [-c name] [-d confdir] [-n configName] [-shards or -s #] [-replicationFactor or -rf #] [-p port]

The list of 6 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 a Solr Windows installation, the solr script is called using solr.cmd.

3. Options for the solr create command

For the solr create command the -c option is required. The other options (parameters) are optional.

Syntax Purpose Default
bin/solr create with only -c <name> input Create a Solr core or collection with default options named <name>.
  • -c <name>
  • -d <name>
  • -n _default
  • -s 1
  • -rf 1
  • -p 8983
-c <name> Select a name for the core (standalone mode) or collection (SolrCloud mode). -c <name> is required
-d <confdir> Select the configuration directory contents to copy to the core in standalone mode or collection in SolrCloud mode. Currently two options exist:
  • _default - a basic configuration option
  • sample_techproducts_configs - a more advanced configuration set that can be used with the techproducts example data set provided by Apache.
You can also pass an alternative location using a path, such as /mycustomconfigs. In SolrCloud mode by default the script will create a directory in ZooKeeper and copy the _default configurations that include the lang directory and files:
  • lang
  • managed-schema
  • params.json
  • protwords.txt
  • solrconfig.xml
  • stopwords.txt
  • synonyms.txt
_default
-n <configName> (SolrCloud mode only) This option is only available in SolrCloud mode. Also it is optional. You can select a name for the configuration directory set up by the -d <confdir> option. By default the name selected will match that selected with -c <name> and contents will be copied to it from the _default directory. This option is provided if a desired configuration directory already exists. <name> from the -c option
-shards <#> or -s <#> (SolrCloud mode only) Set the number of shards to split the collection into. 1
-rf <#> (SolrCloud mode only) Set the number of copies of each document in the collection. The option can be specified using the long form -replicationFactor <#> as well. 1 (not replicated)
-p <port> Select the port on the server where Solr should create the core or collection. Solr selects the first running server

4. Examples of the solr create command

Example 1 - Create a Solr core

The following command creates a Solr core named mycore creating a new configuration set called mycore by copying configurations from /server/solr/configsets/_default.

$ bin/solr create -c mycore
Example 2 - Create a Solr core on a non-default port

The following command will create a Solr core called mycore on port number 8984 instead of the default 8983. This also creates configuration directory called mycore with a copy of contents from /server/solr/configsets/_default.

$ bin/solr create -c mycore -p 8984
Example 3 - Create a Solr collection

The following command will create a Solr collection with the name mycollection on port 8983.

$ bin/solr create -c mycollection -p 8983
Example 4 - Create a Solr collection and renaming techproducts configs

The following command will create a Solr collection named mycollection copying the techproducts configuration to a directory called myconfigs.

$ bin/solr create -c mycollection -d sample_techproducts_configs -n myconfigs
Example 5 - Create a Solr collection with 2 shards and 2 replicas

The following command will create a Solr collection named mycollection with 2 shards and 2 replicas using the _default configurations copied and named mycollection.

$ bin/solr create -c mycollection -s 2 -rf 2
Example 6 - Print additional help on the solr create_core command

From the command line you can access additional help on the solr create_core command by appending -help after the command. The help provided by bin/solr create -help is limited.

$ bin/solr create_core -help
Example 7 - Print additional help on the solr create_collection command

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

$ bin/solr create_collection -help

Other Related Solr Content

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


What's Next?

Learn Apache Solr using a more linear approach with our video tutorials offered for free at our YouTube Channel.

Outline Back Tip Next

/ factorpad.com / tech / solr / reference / solr-create.html


solr create
apache solr
solr reference
enterprise search
apache Lucene
lucene reference
apache Solr search
solr examples
solr commands
solr syntax
solr create
solr wiki
solr settings
solr configuration
solr man page

A newly-updated free resource. Connect and refer a friend today.