I had success on a Drupal 7 project using the example docker-compose-solr.yaml file from version 1.11.0 of DDEV.
Copy https://github.com/drud/ddev/blob/v1.11.0/pkg/servicetest/testdata/services/docker-compose.solr.yaml into your .ddev folder and ensure line 34 matches the solr version you're going to copy from step 2 below, eg solr: 6.6
Copy the files from sites/all/modules/contrib/search_api_solr/solr-conf/6.x/*.*
into the .ddev/solr/conf
folder.
Download and enable search_api_override
module.
Add the following in settings.local.php
:
// For ddev only.
$conf['search_api_override_mode'] = 'load';
$conf['search_api_override_servers']['content'] = array(
'name' => 'DDEV: Solr Server',
'options' => array(
'host' => 'solr',
'port' => '8983',
'path' => '/solr/dev',
'http_user' => '',
'http_pass' => '',
'excerpt' => 0,
'retrieve_data' => 1,
'highlight_data' => 0,
'http_method' => 'AUTO',
),
);
Also, ymmv. It may be better to only override the values you need individually… a la:
$conf['search_api_override_servers']['content']['options']['host'] = 'solr';
$conf['search_api_override_servers']['content']['options']['port'] = '8983';
$conf['search_api_override_servers']['content']['options']['host'] = '/solr/dev';
You may need to modify 'content'
array index to match whatever you configured in Drupal 7 to be your Solr index's machine name.
Start ddev with ddev start
.
NOTE, I place the Search API override values in sites/default/settings.local.php
instead of what one would think to be the logical place (sites/default/settings.ddev.php
) so as not to interfere with DDEV's own auto-generation of the latter file.
It would be cool if DDEV did this automatically in settings.ddev.php
similar to how the DB service settings work, but AFAICT this level of integration is not there and likely never will be for Drupal 7. Firstly, because you need an additional module (search_api_override) that may or may not be present, and secondly because users have the ability to name their Solr server whatever they want, so it would be hard to automate that. E.g. $conf['search_api_override_servers']['content']
could be anything like: $conf['search_api_override_servers']['foo']
.