What is Solr?
Apache Solr is an open source search platform used by most websites so that it can search, index across the site and provide the required content. Solr is a Java application and thereby independent of any platform. In this blog, we will discuss how to replace drupal’s default search with Solr to get better performance.
Prerequisites: To install Solr on the windows system, we should have Java installed on our machine. So install Java setup and configure JAVA_HOME variable.
Step 1: Install Solr
Download the Solr distribution from http://lucene.apache.org/solr/downloads.html. It is usually recommended to use the latest stable version available as it will offer the best performance and most features.
Extract the downloaded Solr archive onto any location of your machine. In our case, its E:\solr-6.6.0. Then navigate to the path, which is E:\solr-6.6.0\bin from the command line and execute the following command.
As soon as you run the above command, Solr will start with default port 8983. You can run the Solr server on any other port by specifying it in the command e.g
solr start -p 8983. Now you can access the Solr admin console on the URL http://localhost:8983/solr/ from your web browser.
Step 3: Install and Configure Drupal modules
*Note that Search API Solr module requires Solarium PHP library to work. We can install it by using composer.
composer require solarium/solarium
Step 4: Configure Solr Core
A new core needs to be added to the Solr server to index the content from Drupal system. To add a new Solr core follow the directions specified hereunder:
2. Now create a file named core.properties in the newly created core folder. It should look like below:
3. Now copy the Solr core configuration schema files from the Search API Solr module folder. Navigate to your module installation directory and look for the folder solr-conf. Here you can find the core schema files for each version of Solr (4, 5, and 6).
4. As Solr-6.6.0 version has been installed, copy the files from the folder 6.x into the conf directory of the newly created core folder.
Step 5: Setup Solr on Drupal
Get to the Search API’s administration page at Admin-> Configuration ->Search and Metadata -> Search API and Click on Add Server. Specify various information e.g server name, solr host, solr port along with other information and save.
Now the Drupal8 system has an active Solr connection.
Thereby, successfully configured the Solr Server on Drupal8 Instance. In the next part, will continue with indexing contents and integrating the indexed data with views in Drupal8.