Enabling Solr Integration
To enable Solr for all environments add the following to your .skpr/defaults.yml Skpr project config file and deploy. It's that simple.
The following example deploys a Solr 7.x instance with a standard Drupal Search API Solr 3.x configuration.
services: solr: default: version: 7.x-3.x
- 5.x-1.x (Legacy)
- 7.x-3.x (Solr 7.x / Search API Solr 3.x)
- 7.x-4.x (Solr 7.x / Search API Solr 4.x)
Configuring your Application
Now that the application is deployed, we can now connect to the newly provisioned Solr instance.
Solr connection details are exposed using the Skpr config system, the same system which is used to wire up connectivity to databases, filesystems, APIs etc.
Below shows the config key/value pairs which are set by Skpr for the newly provisioned Solr service.
$ skpr config list prod | grep solr solr.default.core default solr.default.host 188.8.131.52 solr.default.port 8983
NOTE: Not a real IP listen above.
Applications can automatically detect these configuration values using the recipes below.
For Drupal 8+ we have found the following configuration to work, however, it will vary based on:
- Search API Server Name, in this example it is set to "solr".
- Solr Service Name, in this example it is set to "default".
Add the following to your applications settings.php file.
$config['search_api.server.solr']['backend_config']['connector_config']['host'] = $skpr->get('solr.default.host') ?: '127.0.0.1'; $config['search_api.server.solr']['backend_config']['connector_config']['port'] = $skpr->get('solr.default.port') ?: '8983'; $config['search_api.server.solr']['backend_config']['connector_config']['core'] = $skpr->get('solr.default.core') ?: 'drupal';
Skpr is currently roadmapping the ability for projects to add their own custom configuration to the Solr service.
This is most likely going to be integrated into the same
skpr package process that builds and deploys your application.