How to Integrate Apache Solr with Sitecore 9.1 using SearchStax
SearchStax® can be used to enable Apache Solr on a Sitecore website.
- Install Sitecore 9.1 without Solr
- Create a New Deployment in SearchStax.
- Install the Zookeeper script.
- Upload the Sitecore Configuration Files.
- Create Sitecore Collections.
- Configure Sitecore to use SearchStax.
- Populate Schema from the Control Panel.
Install Sitecore 9.1 without Solr
This section describes how to install Sitecore 9.1 locally without Solr. We'll connect it to a SearchStax Solr deployment in a subsequent step.
Visit the Sitecore Experience Platform 9.1 Initial Release page. Under Download Options for On Premises Deployment, download Packages for XP Single.
Under Release Information, download the Installation Guide and the Quick Installation Guide.
With the exception of Solr, install all the prerequisite sub-components as mentioned in the installation guide.
- Make the following changes in the configuration files.
- XP0-SingleDeveloper.ps1: Comment out or remove the Solr root and
- XP0-SingleDeveloper.json: Comment out or remove the XConnectSolr
and SitecoreSolr "includes:"
- Sitecore-XPO: Comment our or remove the UpdateSolrSchema task:
- Xconnect-xp0: Comment out or remove the ConfigureSolrSchemas task.
- Once all the above changes have been made, go ahead with the Sitecore installation by
running the PowerShell script .\XP0-SingleDeveloper.ps1 as recommended in
the Sitecore installation guide.
Create a New Deployment in SearchStax
Assuming you have already created a SearchStax account and do not already have a deployment set up, click on the Cloud Manager tab and then click on the Create Deployment button at the top. Enter a deployment name, and select the most appropriate provider, region, plan, and Solr version for your needs.
A self-managed Sitecore project may use any of our cloud providers for the Solr deployment.
Single Node or Cluster
Sitecore will work with a single-node deployment (the "DN" series of SearchStax deployments) for purposes of testing and evaluation. However, a production system requires a SearchStax cluster (the "DC" series) to provide high-availability and failover features.
The following table shows Solr versions that are compatible with both Sitecore and with SearchStax. These combinations have been tested; other combinations may or may not work successfully.
Once you create your deployment, you will see it in the Solr Deployments dashboard.
Clicking on the name of the deployment gives you pertinent information about your deployment's servers. The Solr HTTP Endpoint takes you to your Solr server dashboard.
Install the Zookeeper Script
Apache ZooKeeper is a centralized service for maintaining configuration information. In a SearchStax Solr deployment, Zookeeper acts as a centralized repository for your Solr configuration files.
SearchStax users do not have direct access to the Zookeeper configsets as they would in a local Solr installation. Instead, they interact with Zookeeper through a modified version of Solr's standard zkcli script. SearchStax provides both Linux and Windows versions of the script.
You can download the zkcli ZIP file here: searchstax-client-master.zip.
Unzip the file. The top-level directory is \searchstax-client-master. Navigate to the solr-5, solr-6, or solr-7 scripts subdirectory (such as \searchstax-client-master\solr-7\scripts). Locate zkcli.sh and zkcli.bat in that directory. These are the Windows and Linux versions of the script, respectively.
Learn about zkcli
The zkcli script is an all-purpose toolkit for managing Zookeeper on a cloud deployment. See What else can I do with the zkcli script?
Upload the Sitecore Configuration Files
Follow these steps to upload the Sitecore Solr configuration to Zookeeper:
- Download Solr 7.2.1 and extract the file onto a local system.
- Locate the configset folder in solr\solr-7.2.1\server\solr.
- Copy/Duplicate the _default folder into to a new sitecore_configs folder.
- In this new folder, open the managed-schema file in the conf folder and do the following:
- Set the value in <uniqueKey>id</uniqueKey> to _uniqueid.
- In the fields section, add the following field configuration for _uniqueid:
<field name="_uniqueid" type="string" indexed="true" required="true" stored="true"/>
- Use the zkcli.bat script to run this command:
./zkcli.bat -zkhost <zookeeper URLs> -cmd upconfig -d sitecore_configs -n sitecore
where <zookeeper URLs> corresponds to the URL of the Zookeeper ensemble in the deployment details page:
Create Sitecore Collections
When you have uploaded the Solr configuration to Zookeeper, you can create Sitecore collections by following these steps:
- Navigate to the Collections page in the Solr Admin UI.
- Click Add Collection.
- In the config set field, click the Sitecore configuration.
- Specify the following fields as shown:
Pay attention to ReplicationFactor
Use replicationFactor=1 for a single-node deployment. A cluster should have replicationFactor=n (where n is the number of servers in the deployment). This is essential for a high-availability cluster.
- Repeat for all Sitecore indexes.
Configure Sitecore to Use SearchStax
Follow these steps to configure Sitecore to use SearchStax as the search provider:
- Open the web.config file. Under <AppSettings>, change the value
of the search:define key to "Solr".
<AppSettings> <add key="role:define" value="Stanalone"/> <add key="search:define" value="Solr"/> </AppSettings>If there is no search:define key, you may add it.
- Open the ConnectionStrings.config file
in the inetput\wwwroot\<Sitecore Instance name>.sc\App_Config\ folder.
Specify the value of the solr.search key and add the
<add name="solr.search" connectionString="<Solr HTTP Endpoint>;solrCloud=true"/>
- Optionally, if you use SearchStax to configure
Solr Basic Authentication, you will need
to add a user's credentials to the connection string as shown:
<add name="solr.search" connectionString="https://username:password@<loadbalancer>/solr;solrCloud=true"/>
Populate Schema from the Control Panel
Follow these steps to populate the Solr schema:
- Log in to the Sitecore Content Management environment.
- Open the Sitecore Control Panel.
- In the Indexing tab, click Populate Solr Managed Schema.
- Select all indexes and click Populate.
If you are interested in the Sitecore SwitchOnRebuild feature, see Can we use Sitecore's SwitchOnRebuild with SearchStax?
Do not hesitate to contact the SearchStax Support Desk.