Setting up Solr on Silverstripe Cloud
Note: Using Solr on Silverstripe Cloud requires an additional server per environment to host the configuration and resources for Solr. If you require one, please talk to your account manager or contact the Service Desk. This document is only relevant to Solr environments created after April 1st 2019.
Some Silverstripe Cloud environments make use of the Solr search engine, if your stack does there are some prerequisites:
SS3 only: If using a fulltextsearch version only compatible with Silverstripe CMS 3 sites you will need to create a custom Solr Config Store identical to this and reference that in the call to
'mode' => 'MyCustomConfigStore',.
The same Solr server can be used across the base stack and its virtual stacks but please ensure the index names are different per stack to avoid using the index from stack A on stack B etc. To re-use the Solr server between base and virtual environments make sure to copy the Solr environment variables from the base stack to the virtual stacks.
The following is the minimum Solr configuration required in your
_config.php file for a Silverstripe CMS 4 site:
use SilverStripe\FullTextSearch\Solr\Solr; use SilverStripe\Core\Environment; Solr::configure_server([ 'host' => Environment::getEnv('SOLR_SERVER'), 'port' => Environment::getEnv('SOLR_PORT'), 'path' => Environment::getEnv('SOLR_PATH'), 'version' => Environment::getEnv('SOLR_VERSION'), 'indexstore' => [ 'mode' => Environment::getEnv('SOLR_MODE'), 'path' => Environment::getEnv('SOLR_INDEXSTORE_PATH'), ], ]);
SOLR_* environment variables will be automatically set by the Silverstripe Cloud team after your Solr server has been created. A full deployment will be required in order for them to be applied to each environment.
A cron is also required to run the queued fulltext search jobs, this needs to be added to
crons: queuedjobs_task: time: '* * * * *' sake_once: "dev/tasks/ProcessJobQueueTask" vhost: "mysite"
For a virtual stack, replacing “vstack” with your virtual stack’s code:
crons: <vstack>_queuedjobs_task: time: '* * * * *' sake_once: "dev/tasks/ProcessJobQueueTask" vhost: "vstack"
Once you have this configuration in place you can begin creating your indexes following the documentation.