In this article, we are going to learn how Drupal search can be improved with Solr which provides great performance and is suitable even for use on large commercial websites. And along with this using the search_api
& search_api_solr
modules, helps to configure the Facets & Multilingual content can be handled in an improved manner. And let's see how we can configure this locally with the help of Lando, which provides the container for Solr locally.
Assuming you already have a Drupal 9 basic setup with Lando, where you have the web server & mysql running, means you Drupal 9 site is up running with such a url - drupal9.lndo.site
To set up Solr locally, you have to add Solr related configuration in your .lando.yml
file. Here’s the sample of the configuration.
name: drupal9 recipe: drupal9 config: webroot: web services: appserver: type: php:7.4 database: type: mysql healthcheck: '' solr: type: solr portforward: true core: drupal9 config: conf: solr/conf proxy: appserver: - drupal9.lndo.site solr: - solr.lndo.site
It will spin up a container with name solr
type: solr
means, it will pick the latest solr version, currently it picks Solr 7.core: drupal9
means, Solr core nameconf: utils/solr7/conf
means, Create a conf folder under the folder mentioned and download the conf fromsearch_api_solr
- https://git.drupalcode.org/project/search_api_solr/-/tree/4.x/jump-start and place it in the conf folder.
You can access the Admin side of Solr via Solr.lndo.site
. By this you are done with the Solr configuration within Lando on your local machine.
Next thing is to enable the search_api
& search_api_solr
module on Drupal 9.
- Like any other module download these two modules
search_api
&search_api_solr
with lando composer or with lando drush. - Add the Server on Drupal side, by choosing Backend as solr & Standard connecter with the Solr core name as drupal9.
- Leave other details as default and Save server configuration.
- Next you have to add Fields which you wish to Index.
- Later, Create a View to check the indexed content.
This is how we can configure Solr 7 locally with the help of Lando. And using search_api
& search_api_solr
modules adds more flexibility to index & search content.
In Solr 7 we have two major features like Replication modes & Auto Scaling (details can be found here - https://solr.apache.org/guide/7_0/major-changes-in-solr-7.html).
From the Search performance perspective, Solr would play a major role, Thanks to that for Solr. & Thanks to Lando for Solr lando setup & Thanks to module maintainers for search_api
& search_api_solr
for adding flexibility to index & search content.