Configure SolrCloud for Crafter

Crafter Search allows defining a CloudSolrClient in Spring config. This section details how to configure SolrCloud for Crafter CMS.

In Authoring

  1. Zip up (with tar.gz) the directory https://github.com/craftercms/search/tree/master/crafter-search-provider/solr/configsets/crafter_configs/conf.

  2. Copy the zip to one of the Solr servers and unzip it

  3. Go to SOLR_INSTALL_DIR/server/scripts/cloud-scripts.

  4. Run the command ./zkcli.sh -zkhost ZOOKEEPER_HOST:ZOOKEEPER_PORT -cmd upconfig -confname crafter_configs -confdir PATH_TO_UNZIPPED_CONFIGS (make sure the folder at PATH_TO_UNZIPPED_CONFIGS contains the solrconfig.xml file and remember to replace ZOOKEEPER_HOST and ZOOKEEPER_PORT with the actual Zookeeper host and port).

  5. Go to one of the Solr Admin Consoles.

  6. Go to Collections and click on Add Collection.

  7. Make the name of the collection the same as your site name, pick crafter_configs in config set and then click on Add Collection.

  8. Stop Authoring if it’s running.

  9. Go to CRAFTER_INSTALL/bin/apache-tomcat/conf/Catalina/localhost and create the file crafter-search-solrcloud.xml with the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <Context>
        <Environment name="crafter.search.extension.base" value="classpath*:crafter/search-solrcloud/extension" type="java.lang.String" override="false"/>
    </Context>
    

  10. Go to CRAFTER_INSTALL/bin/apache-tomcat/webapps and duplicate the crafter-search.war with the name crafter-search-solrcloud.war.

  11. Go to CRAFTER_INSTALL/bin/apache-tomcat/shared/classes/crafter, create the folders search-solrcloud/extension, and inside create the file services-context.xml with the following content:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
        <bean id="crafter.solrClient" class="org.craftercms.search.utils.spring.CloudSolrClientFactoryBean">
             <property name="zkHost" value="ZOOKEEPER_HOST:ZOOKEEPER_PORT"/>
        </bean>
    </beans>
    

    Remember to replace ZOOKEEPER_HOST and ZOOKEEPER_PORT with the actual Zookeeper host and port.

  12. Go to CRAFTER_INSTALL/data/deployer/targets and create a new target with the name of your site, followed by -solrcloud (e.g. editorial-solrcloud.yaml). Add the following content (changing the SITE_NAME and the SITE_REPOS_PATH):

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    target:
    env: solrcloud
    siteName: SITE_NAME
    localRepoPath: SITES_REPOS_PATH/published
    search:
      serverUrl: http://localhost:8080/crafter-search-solrcloud
    deployment:
      scheduling:
         enabled: true
      pipeline:
        - processorName: gitDiffProcessor
        - processorName: searchIndexingProcessor
        - processorName: fileOutputProcessor
    

  13. Start Authoring again. After a scheduling period (normally 1 minute), the Deployer will send the published site content for indexing to the SolrCloud.

In Delivery

  1. Stop Delivery if it’s running.
  2. Copy the same configuration in step 11 of the previous section under CRAFTER_INSTALL/bin/apache-tomcat/shared/classes/crafter/search/extension/services-context.xml.
  3. Go into the Deployer target of the site: CRAFTER_INSTALL/data/deployer/targets/SITE_NAME-default.yaml, and comment the line with the searchIndexingProcessor (e.g. #- processorName: searchIndexingProcessor).
  4. Start Delivery again. Crafter Search should now read from the SolrCloud, and the Deployer won’t index changes since the processor is now commented.