FactorPad
Build a Better Process

The Solr create core Command Syntax and Examples

This command is one of three Solr commands used to create cores and collections at the command line. it is specifically used to create cores in standalone mode, typically for delivoping a test environment.
  1. About - understand the purpose of the create core command.
  2. Syntax - see solr create core command usage from the command line.
  3. Options - view 3 options used with the solr create core 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-core.html


An ad-free and cookie-free website.


The Solr create core Command

Beginner

The search business is evolving and those with needs to develop capabilities in enterprise search and website search have two choices: buy or build. First, offerings from Google Custom Search and Amazon CloudSearch and a few other players offer a managed search option. The second option is to build a custom search application using the open-source Lucene search library and customize it with Apache Solr search or Elasticsearch.

Any comprehensive review of the choices requires building a test environment first which is normally performed on one server in what is called standalone mode in Solr. Next, as search volumes increase and the search application moves to production it is important to review distributed search in Apache Solr that sits in SolrCloud mode.

Tests in Solr search require building test data sets and configurations for managing the search application. Here with solr create_core you create a core in standalone mode. The solr create_collection command on the other hand is used in SolrCloud mode for distributed search.

Apache Solr Reference

1. About the solr create core command

The solr create_core command has a more limited set of capabilities because cores run on one server and data is not replicated and served by two instances.

The other two commands in this set include the solr create command which is covered in the previous page (click Back). It interprets the mode and uses solr create_core command functionality in standalone mode. If it interprets SolrCloud mode then it uses the functionality of the solr create_collection command (click Next).

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

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

2. Syntax for the solr create core command

The syntax for running solr create_core is as follows.

$ bin/solr create_core [-c name] [-d confdir] [-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 a Solr Windows installation, the solr script is called using solr.cmd.

3. Options for the solr create core command

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

Syntax Purpose Default
bin/solr create_core with only -c <name> input Create a Solr core with default options named <name>.
  • -c <name>
  • -d <name>
  • -p 8983
-c <name> Select a name for the core in standalone mode. -c <name> is required
-d <confdir> Select the configuration directory contents to copy to the core in standalone 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. The script will create a directory 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
-p <port> Select the port on the server where Solr should create the core. Solr selects the first running server

4. Examples of the solr create core 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_core -c mycore
Example 2 - Create a Solr core with a non-default config directory

The following command will create a Solr core named mycore but with a configuration directory named mycoreconfigs. This is not advised.

$ bin/solr create_core -c mycore -d mycoreconfigs
Example 3 - 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 a configuration directory called mycore with a copy of contents from /server/solr/configsets/_default.

$ bin/solr create_core -c mycore -p 8984
Example 4 - 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.

$ bin/solr create_core -help

Other Related Solr Content

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


What's Next?

Our YouTube Channel is packed with free turorials for developers. It is growing and we would love if you joined us there.

Outline Back Tip Next

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


Solr create core
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
man page

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