Skip to main content

Setting Up Solr Search in Drupal 10 on Lando

In Drupal, when we need to search for content, we mostly use the Search API module, which includes the default Database Search module. The Database Search module uses the Drupal database to search for any content within it. This search method is best for sites with minimal data, but for more complex sites with hundreds of thousands of records, it might slow down or even break the site.

To implement search functionality on larger sites, we can use different search services like Solr Search or Elasticsearch. Solr is the most popular search service for handling searches on larger sites. In this blog, we will set up Solr search on our local Lando setup. Here are the steps to set up Solr search on a local Lando setup.

Steps:- 

Step 1 -  Setting up the .lando.yml file

name: drupal-test
recipe: drupal10
config:
  webroot: web
services:
  solr:
    type: solr:8.6
    core: drupal
    portforward: true
    config:
      conf: solr/conf
proxy:
  solr:
    - search.drupal-test.lndo.site:8983

In this file, we have applied the following changes:

  • Added the Solr service with version 8.6 (you can modify the Solr version according to your needs).
  • Configured the core for Solr search with the name "drupal".
  • Added the config directory path to solr/conf (we need to manually create this directory at the root of the project where we added the .lando file).
  • Added the proxy for the Solr service.

Step 2 -  Rebuild the Lando application

lando rebuild -y

Step 3 -  Install the required modules and enable them

Install the following modules using Composer and enable them using Drush or from the backend:

Step 4 -  Configure the search server and index

Go to the Search API configuration page at /admin/config/search/search-api and add the server and index.

Step 5 - Configure the solr server

Use the following settings to configure the Solr server:

Solr Connector:- Standard
Solr host: solr
Solr port: 8983
Solr path: /
Solr core: drupal

Step 6 -  Configure the Search index

Now, configure the search index, choose the Solr server, and start indexing the content.

Step 7 - Create the search view page and configure the view.

After configuring the server and index, create the view page for the Solr search.

Image
solr

 

By following the above steps you will now be able to use the solr search in your local lando setup without any issues.

 

Related Articles