Sitecore and Solr — How to Add Custom Indexes to Sitecore using SearchStax
SearchStax® Managed Solr can be used to add custom indexes on a Sitecore website.
Therefore, you already have a Sitecore site that is connected to a compatible Managed Solr deployment. You have access to the Solr Dashboard, and you have prepared Solr configuration files for your custom collections, including a custom Managed Schema file.
Install the Zookeeper Script
Apache ZooKeeper is a centralized service for maintaining configuration information. In a Managed 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, solr-7, or solr-8 scripts subdirectory (such as \searchstax-client-master\solr-8\scripts). Locate zkcli.bat in that directory. This is the Windows version of the script.
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?
Zookeeper Best Practice
For truly secure Zookeeper management, use the SearchStax Zookeeper API. The API’s Zookeeper methods require SearchStax user authentication, and they record entries in the Managed Solr access logs. See How can I secure Zookeeper?for more information.
Upload the Sitecore Configuration Files
We assume that you have a directory of configuration files prepared for your custom Sitecore collection.
Follow these steps to upload the Solr configuration for your new collection:
- 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 <config_directory> -n <config_name> where <config_directory> is the local custom configuration directory, <config_name> will be the name of the custom configuration on Zookeeper, and <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 <config_name> is similar to that shown below.
Create Sitecore Collections
Pay attention to ReplicationFactor
Use replicationFactor=1 for a single-node deployment. A two-node cluster should have replicationFactor=2. You need the same number of replicas as Solr servers.
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 Dashboard.
- Click Add Collection.
- In the config set field, click the Sitecore configuration.
- Specify the following fields as shown:
- Repeat for each of the custom collections you wish to add.
Do not hesitate to contact the SearchStax Support Desk.