Install and use Solr 6.5 with CKAN

Jakub Klímek edited this page Mar 31, 2017 · 1 revision
Clone this wiki locally


In this tutorial we are going to install Solr 6.5 on our server (no compilation required!) and set up a core for CKAN.

Solr 6.5 comes with a nice script for install the package in the system, it detect the OS and eventually creates the solr user for the daemon.

Download and Install Solr

Go to the Apache Solr website and download Solr, in this tutorial we are going to use the .tgz format, but it works with .zip as well.

Download the package from the web and put it somewhere in your file-system, we are going to use the installer soon


when the download is finished, unzip the package and go to the bin directory

unzip solr-6.5.0.tgz
cd solr-6.5.0/bin

as root, we need to create the install directory and execute the file This script accepts arguments if we need to install the daemon to listen ad different port or with another user.

Usage: path_to_solr_distribution_archive OPTIONS

  The first argument to the script must be a path to a Solr distribution archive, such as solr-6.5.0.tgz
    (only .tgz or .zip are supported formats for the archive)

  Supported OPTIONS include:

    -d     Directory for live / writable Solr files, such as logs, pid files, and index data; defaults to /var/solr

    -i     Directory to extract the Solr installation archive; defaults to /opt/
             The specified path must exist prior to using this script.

    -p     Port Solr should bind to; default is 8983

    -s     Service name; defaults to solr

    -u     User to own the Solr files and run the Solr process as; defaults to solr
             This script will create the specified user account if it does not exist.

 NOTE: Must be run as the root user

If we want to install everything to /opt/solr

sudo ../../solr-6.5.0.tgz

note that we use the .tgz file as argument to the script, change the path if you need.

Now the script installs the binaries under /opt/solr, it puts the init script under /etc/init.d/solr and eventually create the solr user.

Create and configure the core

Switch to the solr user and go to the bin directory

sudo su solr
cd /opt/solr/bin

now create the ckan core

./solr create -c ckan

solr creates all the configuration files and directories. At this point, we can see the core listed in our solr admin http://localhost:8983/solr and we can proceed to edit the configuration files

cd /var/solr/data/ckan/conf

open solrconfig.xml and insert following line into the root <config> element:

<schemaFactory class="ClassicIndexSchemaFactory"/>

Delete this element:

<initParams path="/update/**">
  <lst name="defaults">
    <str name="update.chain">add-unknown-fields-to-the-schema</str>

and also delete this element:

<processor class="solr.AddSchemaFieldsUpdateProcessorFactory">
  <str name="defaultFieldType">strings</str>
  <lst name="typeMapping">
    <str name="valueClass">java.lang.Boolean</str>
    <str name="fieldType">booleans</str>
  <lst name="typeMapping">
    <str name="valueClass">java.util.Date</str>
    <str name="fieldType">tdates</str>
  <lst name="typeMapping">
    <str name="valueClass">java.lang.Long</str>
    <str name="valueClass">java.lang.Integer</str>
    <str name="fieldType">tlongs</str>
  <lst name="typeMapping">
    <str name="valueClass">java.lang.Number</str>
    <str name="fieldType">tdoubles</str>

Next, remove the managed-schema file

rm managed-schema

and copy or symlink the schema.xml from CKAN:

cp /somewhere/over/the/rainbow/ckan/conf/solr/schema.xml .


ln -s /usr/lib/ckan/default/src/ckan/ckan/config/solr/schema.xml schema.xml

Finally, restart solr

/etc/init.d/solr restart


sudo service restart solr