Install Apache Solr on a Drupal 10 Website using Managed Search


Overview

The SearchStax Managed Search service can be used to install Apache Solr on a Drupal 10 website using Drupal’s Search API and its Search API Solr modules.

This article was based on a blog post – How to Set Up a Drupal Website Connected to a SearchStax Solr Deployment – by Thomas Hada of Anant.

This example uses Drupal 10.1.4 and Solr 8.11.2. Learn more about the Drupal 10 digital experience platform (DXP).

Basic Steps:

  1. Create a new deployment in Managed Search.
  2. Create a Solr Collection.
  3. Install Drupal.
  4. Install the Search API and Search API Solr modules.
  5. Configure the Search API module Server.
  6. Configure the Search API module Index.
  7. Optional – Index your site.
  8. Optional – Secure your site

Step 1: Create a New Deployment in Managed Search

Assuming you have already created a SearchStax account and do not already have a deployment set up, click on the Dedicated tab and then click on the Create New Deployment button at the top. Enter a deployment name, and select the most appropriate region, plan, and Solr version for your needs. In this example we will be using Solr 8.11.2.

Once you create your deployment, you will see it in the Deployments dashboard.

Clicking on the name of the deployment will give you pertinent information about your deployment’s servers. The Solr HTTP Endpoint will take you to your Solr server dashboard.

Click on Auth in the Security tab to create an Authentication username and password. Enable Auth.

Add a user with Admin permissions. Keep your credentials handy for next steps.

Step 2: Create a Solr Collection

Create a new Solr collection using the commands below. For now, use the _default config for the collection.configName parameter. Later in the guide, we will replace the config with one Drupal recommends.

The username and password is the one you defined in Step 1 when adding an Admin user.

Create New Collection:

Linux:

> curl '<Solr HTTP Endpoint>admin/collections?action=CREATE&name=<collectionName>&collection.configName=<configName>&numShards=1' --user username:password

Windows:

$ curl.exe "<Solr HTTP Endpoint>admin/collections?action=CREATE&name=<collectionName>&collection.configName=<configName>&numShards=1" -k -u username:password

Step 3: Install Drupal

We will assume you have Drupal 10 installed. If not please refer to the official Drupal 10 installation page.

Step 4: Install Search API / Search API Solr Module

Install the Drupal Search API Module.

Once the Search API is installed, you can add the Search API Solr Module.

Before continuing, you may need to install the Composer Dependencies.

Finally, you will need to enable the installed modules. Enable the following items: Search API and Search API Solr, and Search API Solr Admin.

Step 5: Configure the Search API Module

Now that the modules have been enabled, click on the Configuration tab. Look for section SEARCH AND METADATA and click on Search API to configure it.

Once there, click Add Server.

Give your server a name. Make sure the Backend is set to Solr. Check that HTTP protocol is set to https. The Solr host is the deployment’s Solr HTTP Endpoint without the /solr/ element. For incoming connections from Drupal, the Solr port is always 443. The Solr core is the name of the collection defined in Step 2.

Note that the Solr path was /solr in version 8.x-2.7 of the Search API Solr Module, but it changed to / (no “solr”) in version 8.x-3.1. See Upgrade Search API Solr from 2.x to 3.1 for further information.

Add the Solr node, Solr port, and Default Solr Collection. The Solr node can be found in the Endpoints section of your deployment under Solr HTTP Endpoint. The port is 443. The Default Solr Collection is the Collection you created in step 2.

Ensure you’ve added the correct Basic Authentication username and password defined in Step 1.

Click save at the bottom of the page.

If your configuration settings are valid, you will see a message saying that the information was saved successfully. Under Server Connection, it should read “The Solr server could be reached”. If not, you need to redo adding a Server.

Next we will replace the _default Solr schema causing the error message of incompatible Solr Schema. Click on “upload config.zip”.

Check Upload Button and Click Upload.

You will get a success message.

Step 6: Configure the Search API Module Index

Next you will need to define an index. In the Search API configuration screen, click on Add Index.

Give your index a name, and select the data sources you wish to index. For this example, select Content.

At the bottom of the page make sure that you select the Server created earlier. Click Save and add fields.

Add the fields you would like to Index. Take note of field types.

Step 7: Optional – Index Your Site

A cron job will periodically index your site automatically, but if you want to see your results immediately go to the Search API configuration screen and click on the index created earlier. At the bottom, click on the Index now button.

After you begin, you will see a progress bar. Once it reaches 100%, you will get a success message.

After your site has been indexed, you can view and query the data in Solr.

Step 8: Optional – Secure Your Site

SearchStax and Solr provide some optional security features that can help you lock down your Solr deployment. Please consider some or all of the following security options.

Connecting to the Managed Search Cluster

SearchStax recommends that you situate your application infrastructure in the same local network as your hosting provider (for example, the same AWS or Azure region). Internal network security for these hosting providers is extremely high and eliminates any chance of a hacker potentially sniffing your network traffic.

If your application is hosted elsewhere, try to host it as close to your search infrastructure as possible. This can be done by choosing the Cloud Provider Region which is closest to your application. This improves both security and performance.

Note that all connections to the SearchStax Dashboard use HTTPS, which encrypts your traffic in transit.

IP Filtering

SearchStax can limit access to a deployment to specific IP addresses. You can configure access
for Zookeeper and Solr servers separately. Instructions will be found at SearchStax IP Filtering.

Tenant Users

Each SearchStax account is restricted to the owner (and admin) of that account plus any SearchStax “tenant users” who have been granted access to that account by the owner. The additional users may be enrolled as normal SearchStax operators or as admins at the owner’s discretion. See Managing Users.

Solr Authentication and Authorization

Solr offers an Authentication and Authorization feature that lets you set up username/password protection for the Solr server dashboard. SearchStax makes it very easy to enable this feature.

Note that Solr user accounts are independent of SearchStax user accounts.

If you set a username/password for Solr, you’ll need to edit the Search API server (under “Basic HTTP authentication”) and input the same information there.

The only warning is that enabling/disabling Solr authentication forces the Solr servers to restart. See Solr Authentication and Authorization.

Questions?

Do not hesitate to contact the SearchStax Support Desk.