Solr Server Installation for Standalone Mode

Learn how to install and configure a standalone Solr server in a way that can be used in SAP Commerce.

Quick Installation and Configuration

Context

Follow the steps for a quick installation and configuration of the solr server on your local machine.

Procedure

  1. Enable the solrserver extension in your localextensions.xml file.

    The extension is now ready for use. For further information on configuring extensions, see Installation Based on Specified Extensions.

  2. Create a Solr server instance. You can use the default instance included in the solrserver extension.
    The default configuration is as follows:
    solrserver.instances.default.autostart=true
    solrserver.instances.default.mode=standalone
    solrserver.instances.default.hostname=localhost
    solrserver.instances.default.port=8983
    solrserver.instances.default.memory=512m
    If you need, you can override some of the properties in your local.properties file. For further information, see: solrserver Extension.
  3. Start the SAP Commerce server.

    Because autostart is enabled for the default Solr server instance, the Solr server is started and stopped together with the platform. For further information, see: Installing SAP Commerce Manually and Installing SAP Commerce Using Installer Recipes.

  4. Configure SAP Commerce to use the Solr server.
    The most important attributes you should consider when updating the Solr server configuration are:
    • Mode: set it to standalone.

    • Endpoint URLs: should contain a single master URL with the following value: http://localhost:8983/solr.

    For details on how to easily configure the Solr server settings with the Backoffice Administration Cockpit see: Create Facet Search Configuration.

Solr Server Installation

Using the solrserver Extension

By enabling the solrserver extension in your localextensions.xml file, you get a Solr server instance ready to be used. The default configuration ensures that a standalone Solr server is configured, started and stopped together with the platform. This is convenient in CI or developer environments. Note that the mode property should be set to standalone.

The following code shows an example of a configuration:
# disables the autostart for the default Solr instance
solrserver.instances.default.autostart=false

solrserver.instances.standalone.autostart=true
solrserver.instances.standalone.mode=standalone
solrserver.instances.standalone.hostname=localhost
solrserver.instances.standalone.port=8983
solrserver.instances.standalone.memory=512m

Using an External Standalone Server

Each version of SAP Commerce can support more than one Solr version to maintain compatibility. Each version includes the server directory that contains the server and the applied customizations, and the customizations directory that contains modifications that can be applied to an official Solr release. For the installation steps, see the Installation section in Multiple Solr Version Support.

Use the following commands to start and stop the Solr server:
  • On Linux systems:

    # ./bin/solr start -p 8983
    Waiting up to 30 seconds to see Solr running on port 8983 [/] 
    Started Solr server on port 8983 (pid=23092). Happy searching!
     
    # ./bin/solr stop -p 8983
    Sending stop command to Solr running on port 8983 ... waiting 5 seconds to allow Jetty process 23092 to stop gracefully.
    
  • On Windows systems:

    # bin\solr.cmd start -p 8983
    Waiting up to 30 to see Solr running on port 8983
    Started Solr server on port 8983. Happy searching!
     
    # bin\solr.cmd stop -p 8983
    Stopping Solr process 6256 running on port 8983
    Waiting for 0 seconds, press a key to continue ...

Cluster Configuration

This section describes how to set up a cluster of Solr servers using replication. This is especially useful when:
  • You have a high system load caused by searches and you want to balance the load among several servers

  • Indexing consumes many resources, so you need to separate indexing and searching

In a cluster configuration, there’s a leading server where indexing happens, and one or more subordinate servers. All indexes on the leading server are replicated to each one of the subordinate servers so that both leading and subordinate servers have the same indexes.

You can enable an index replication feature in the Solr instance out of the box. Replication requests are handled by the ReplicationHandler, which can be configured in the solrconfig.xml file. By default, the corresponding section of the solrconfig.xmlfile is commented out:
<requestHandler name="/replication" class="solr.ReplicationHandler" >
  <!--
     To enable simple master/slave replication, uncomment one of the
     sections below, depending on whether this solr instance should be
     the "master" or a "slave".  If this instance is a "slave" you will
     also need to fill in the masterUrl to point to a real machine.
  -->
     <lst name="master">
       <str name="replicateAfter">commit</str>
       <str name="replicateAfter">startup</str>
       <str name="confFiles">schema.xml,stopwords.txt,synonyms.txt</str>
     </lst>
  <!--
     <lst name="slave">
       <str name="masterUrl">http://your-master-hostname:port/solr/${solr.core.name}/replication</str>
       <str name="pollInterval">00:00:60</str>
     </lst>
  -->
</requestHandler>
The following are configuration examples using the solrserver extension:
  • local.properties file:

    solrserver.instances.master.autostart=true
    solrserver.instances.master.mode=standalone
    solrserver.instances.master.hostname=localhost
    solrserver.instances.master.port=8983
    solrserver.instances.master.memory=512m
     
    solrserver.instances.slave.autostart=true
    solrserver.instances.slave.mode=standalone
    solrserver.instances.slave.hostname=localhost
    solrserver.instances.slave.port=8984
    solrserver.instances.slave.memory=512m
    
  • config/solr/instances/master/configsets/default/conf/solrconfig.xml file:

    <requestHandler name="/replication" class="solr.ReplicationHandler" >
         <lst name="master">
           <str name="replicateAfter">commit</str>
           <str name="replicateAfter">startup</str>
           <str name="confFiles">schema.xml,stopwords.txt,synonyms.txt</str>
         </lst>
    </requestHandler>
  • config/solr/instances/slave/configsets/default/conf/solrconfig.xml file:

    <requestHandler name="/replication" class="solr.ReplicationHandler" >
         <lst name="slave">
           <str name="masterUrl">http://your-master-hostname:port/solr/${solr.core.name}/replication</str>
           <str name="pollInterval">00:00:30</str>
         </lst>
    </requestHandler>

SAP Commerce Configuration in Backoffice Administration Cockpit

Update the Solr server configuration using the Backoffice Administration Cockpit.

The most important attributes you should consider are:
  • Mode: set it to standalone.

  • Endpoint URLs: for URLs of the servers that are part of the cluster - one of them should be set as master, for example, http://master:8983/solr, http://slave:8983/solr.

For details on how to easily configure the Solr server settings with the Backoffice Administration Cockpit see Configure the Solr Server.