Sitecore and Solr -- 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
Windows 10 Required
Note that a stand-alone installation of Sitecore 9.1 requires a Windows 10 computer. Other prerequisites may be found in the Sitecore installation documents.
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.
Farther down the same web page, 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: Change the $Prefix to "sitecore".
Comment out the Solr root and service details:
- XP0-SingleDeveloper.json: Comment out or remove the XConnectSolr
and SitecoreSolr "includes:"
- Sitecore-XPO: Comment out 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 _default folder under solr-7.2.1.zip\solr-7.2.1\server\solr\configsets\_default.
- Copy the contents of the _default folder (not the folder itself)
into to a new sitecore_configs folder. The new folder can be anywhere,
such as C:\sitecore_configs. It should look like this when you are finished:
- In this new folder, open the solrconfig.xml file. Set the update.autoCreateFields setting to false (update.autoCreateFields:false).
- 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:
- From the deployment details page, click the Solr HTTP Endpoint link to
open the Solr Dashboard. Verify that the directory structure of sitecore
is similar to that shown below.
Create Sitecore Collections
Pay attention to ReplicationFactor
Use replicationFactor=1 for a single-node deployment. A three-node cluster should have replicationFactor=3. You need the same number of replicas as Solr servers.
- Navigate to the Collections page in the Solr Dashboard.
- Click Add Collection.
- In the config set field, click the Sitecore configuration.
- Specify the following fields as shown:
- 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="Standalone"/> <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:
<add name="solr.search" connectionString="<Solr HTTP Endpoint>"/>
- 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"/>
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.
Do not hesitate to contact the SearchStax Support Desk.