Skip to main content

We are going to work through two methods of creating the SOLR cores.

Variables for reference used in this article:

{ip_address} - your server IP Address

{name} - name of the instance you are creating

{dir} - name of the instance directory you are creating

 

How to create a core in SOLR with API?

http://{ip_address}/solr/admin/cores?action=CREATE&name={name}&instanceDir={dir}&configSet=_default&dataDir=data

Here are details about parameters –

Parameter Value Comments
action CREATE Command to create core
name {name} Name of the core
instanceDir {dir} Directory name
configSet _default Configset to be used
dataDir Data Data directory

 

How to create a core in SOLR manually?

We can create core manually on our local system and then can copy these Cores to Solr instance through uploading via shell or FTP.

Where is the Solr directory located on your server?  If you don't know the location of your solr directory run:

find / -name solr -type d

You can find more information about how to search on Terminal Commands Find.

In my instance the location of Solr was

/var/solr

Access your Solr config directory through:

cd data/ or /var/solr/data/

The initial install of my instance held the following files and directories

  • filestore
  • solr.xml
  • userfiles
  • zoo.cfg

I needed to create a solr core with name production.

Create a directory with name production in the data directory.

mkdir production

Now we need to copy conf folder from \server\solr\configsets\_default location to newly created production directory.

We need to create a text file named core.properties in production directory with following content.

name=[CORE_NAME]
config=solrconfig.xml
update.autoCreateFields=false
dataDir=data

Here we need to provide name as production since it is the name of the core.

We are done with creating the core folder at our local system, now we need to copy this (production) to our cloud instance. For this we can use the FTP and copy it to /var/solr/ location as referenced earlier.

Once the newly Solr core folder (production) copied to cloud instance, restart the Solr App Service to reflect this change. After restarting the newly create core can be seen in core list of SOLR dashboard.

service solr restart

 

Errors

Error CREATEing SolrCore 'production': Unable to create core [production] Caused by: Can't find resource 'solrconfig.xml' in classpath or '/var/solr/data/'

Download a copy of the solr_8 zip file and upload it to your core path.  For example, 

/var/solr/data/production/conf/

As a prompt, the contents of the solr_8.zip conf. will be similar to:

  • accents_en.txt
  • accents_und.txt
  • elevate.xml
  • protwords_en.txt
  • protwords_und.txt
  • schema.xml
  • schema_extra_fields.xml
  • schema_extra_types.xml
  • solrconfig.xml
  • solrconfig_extra.xml
  • solrconfig_index.xml
  • solrconfig_query.xml
  • solrconfig_requestdispatcher.xml
  • solrcore.properties
  • stopwords_en.txt
  • stopwords_und.txt
  • synonyms_en.txt
  • synonyms_und.txt

Post adding these files, reload Solr via the admin interface.

 

Using the admin interface and command line

First using your shell prompt, add the following directories to the location of your Solr directory.

Title Label Location
core name {name} /var/solr/data/{name}
data directory data /var/solr/data/{name}/data
conf directory conf /var/solr/data/{name}/conf

Copy the solr_8.zip (unzipped) into the conf directory.

In the Solr admin interface, click on Add Core with the following details:

Label Title
name {name}
instanceDir /var/solr/data/{name}
dataDir /var/solr/data/{name}/data
config  
schema  

 

 

Related articles