Please consider using ddev/ddev-solr, which runs Solr in the modern “Cloud” mode. This is the recommended and maintained Apache Solr integration. ddev-solr offers several advantages. If you are using Drupal, the biggest advantage
is that you can update the Solr Configset from the UI or with a Drush command everytime you update search_api_solr.
The current addon runs in “classic standalone” mode. It is probably simpler at first to setup, but comes with the added maintenance steps for configsets. Most Solr hosting service providers run “Solr Cloud” as a backend.
Apache Solr is the blazing-fast, open source, multi-modal search platform built on the full-text, vector, and geospatial search capabilities of Apache Lucene™.
This add-on integrates Solr for Drupal 9+ into your DDEV project. It follows the Setting up Solr (single core) - the classic way recipe.
ddev add-on get ddev/ddev-drupal-solr
ddev restart
ddev composer require drush/drush drupal/search_api_solr
search_api_solr module either using the web interface or
ddev drush en -y search_api_solr
admin/config/search/search-api -> “Add server”ddev-solr-server.SolrStandardsolrdev/opt/solr.ddev restartddev add-on get ddev/ddev-drupal-solr.ddev/docker-compose.solr.yaml file. Replace image: solr:8 with image: solr:7 on line 34.search_api_solr/solr-conf/7.x directory . Copy these files into .ddev/solr/conf.ddev restart.http://<projectname>.ddev.site:8983/solr/.drush to the drush8 provided with Ddev. You can do this by adding a post-start hook inside your .ddev/config.yaml file as follows
hooks:
post-start:
- exec: ln -s /usr/local/bin/drush8 /usr/local/bin/drush
ddev restart.ddev drush dl search_api_solr.search_api_solr module either using the web interface or ddev drush en -y search_api_solradmin/config/search/search-api -> “Add server”ddev-solr-server.httpsolr8983/solr/dev.
The “Solr server URI” should be http://solr:8983/solr/dev when done.admin/config/search/search-api -> “Add index”ddev-solr-index-content.contentddev-solr-server (or whaver the name is)ddev-solr-index-content (or whatever the name is)Solr Search.ddev-solr-index-content (or whatever the name is)Search or whatever you prefer/search or whatever you preferHTML list + OL / Rendered entity + Search result view modeSearch: Fulltext search (exposed)Indexed Content: Status (= Published))Search: Relevance (desc)Permission / View published contentInput requiredGlobal:text / No results matched your search.If you get a message about Solr having outdated config files, you need to update the included Solr config files.
.ddev/solr/conf/ddev restartsearch_api_solr/solr-conf/7.x directory ..ddev/solr/conf.ddev restart.See the documentation in the doc folder
| Command | Description |
|---|---|
ddev launch :8943 |
Open Solr Admin (HTTPS) in your browser (https://<project>.ddev.site:8943) |
ddev launch :8983 |
Open Solr Admin (HTTP) in your browser (http://<project>.ddev.site:8983) |
ddev describe |
View service status and used ports for Solr |
ddev logs -s solr |
Check Solr logs |
This originates from the classic Drupal solr:8 image recipe used for a long time by Drupal users and compatible with search_api_solr.
.ddev/docker-compose.solr.yaml using the solr:8 docker image..ddev/solr/conf with just a ddev restart.https://<projectname>.ddev.site:8943/solr/ and http://<projectname>.ddev.site:8983/solr/. For example, if the project is named myproject the hostname will be: https://myproject.ddev.site:8943/solr/.http://solr:8983/solr/http://solr:8983/solr/dev or from the host at https://<projectname>.ddev.site:8943/solr/#/~cores/dev. You can obviously create other cores to meet your needs.If you want to use a core name other than the default “dev”, add a .ddev/docker-compose.solr-env.yaml with these contents, using the core name you want to use:
services:
solr:
environment:
- SOLR_CORENAME=somecorename
SOLR_CORENAME environment variable in the environment: section.You can delete the “dev” core from https://<projectname>.ddev.site:8943/solr/#/~cores/dev by clicking “Unload”.
If you would like to use more than one Solr core, add a .ddev/docker-compose.solr_extra.yaml to override some of the default configuration.
Define a mount point for each core you require. Add new mount points for each core, for example:
services:
solr:
volumes:
- ./solr:/solr-conf
- ./core2:/core2-conf
- ./core3:/core3-conf
Create the directories for your new cores’ config, and copy the desired solr config in to it, eg:
cp -R .ddev/solr .ddev/core2
cp -R .ddev/solr .ddev/core3
cp -R path/to/core2-config/* .ddev/core2/conf/
cp -R path/to/core3-config/* .ddev/core3/conf/
Set the entrypoint value to use precreate-core instead of solr-precreate and add the additional cores, along with a command to start solr afterwards:
services:
solr:
entrypoint: 'bash -c "VERBOSE=yes docker-entrypoint.sh precreate-core solrconf /solr-conf ; precreate-core core2 /core2-conf ; precreate-core core3 /core3-conf ; exec solr -f "'
Your finished .ddev/docker-compose.solr_extra.yaml file should now look something like this:
services:
solr:
volumes:
- ./solr:/solr-conf
- ./core2:/core2-conf
- ./core3:/core3-conf
entrypoint: 'bash -c "VERBOSE=yes docker-entrypoint.sh precreate-core solrconf /solr-conf ; precreate-core core2 /core2-conf ; precreate-core core3 /core3-conf ; exec solr -f "'
Finally, ddev restart to pick up the changes and create the new cores.
solr:8 and beyond. Acquia’s hosting requires Solr 7. You’ll want to follow the Drupal 7 instructions above, or see the contributed recipes for older versions of Solr.Contributed by @rfay
Maintained by @mkalkbrenner, @bserem, and the DDEV team