Solr

Setting up Solr on SSP

Note: Using Solr on SSP 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 helpdesk.

Some SilverStripe stacks make use of the Solr search engine, if your stack does there are some prerequisites:

Firstly, The QueuedJobs and Fulltextsearch modules need to be installed.

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 environment variables from the base stack to the virtual stacks.

The following configuration is required in your _config.php file:

use SilverStripe\FullTextSearch\Solr\Solr;
use SilverStripe\Core\Environment;

Solr::configure_server([
    'host' => Environment::getEnv('SOLR_SERVER') ?: 'localhost',
    'port' => Environment::getEnv('SOLR_PORT') ?: '8983',
    'path' => Environment::getEnv('SOLR_PATH') ?: '/solr',
    'indexstore' => [
        'mode' => Environment::getEnv('SOLR_MODE') ?: 'file',
        'auth' => Environment::getEnv('SOLR_AUTH') ?: null,
        'path' => Environment::getEnv('SOLR_INDEXSTORE_PATH') ?: BASE_PATH.'/.solr',
        'remotepath' => Environment::getEnv('SOLR_REMOTE_PATH') ?: null,
    ]
]);

A cron is also required to run the queued fulltext search jobs, this can be added to .platform.yml:

crons:
  queuedjobs_task:
    time: '* * * * *'
    sake_once: "dev/tasks/ProcessJobQueueTask"
    vhost: "mysite"

For a virtual stack (replacing “” with your virtual stack name:

crons:
  <vstack>_queuedjobs_task:
    time: '* * * * *'
    sake_once: "dev/tasks/ProcessJobQueueTask"
    vhost: "<vstack>"