Improve Drupal Search with Solr, Locally configured via Lando

ByKarthik Kumar D Kon21st Feb 2022, 2022-02-21T19:45:00+05:30
Read Article
Pause
Resume
Stop
Improve Drupal Search with Solr, Locally configured via Lando

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

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.

Comments

We Need Your Consent
By clicking “Accept Cookies”, you agree to the storing of cookies on your device to enhance your site navigation experience.
I Accept Cookies