Apache Solr is a popular and open source search platform that provides a wide set of core search functions and features.
This tutorial will deal with the Drupal 8 search API module and Apache Solr to build a digital experience that enjoys an effective search feature that enables users to obtain better results for their search queries which may or may not include incomplete word-parts.
Before you begin, you will need to have installed Apache Solr on your server.
Step 1. Installing the Drupal Module
Using composer and Drush; install the Search API Solr module by copying and pasting the command below in your terminal:
Next; make sure you’ve configured Solr core via Search API Solr configurations. If you don't know how; click here for a simple guide.
Step 2. Create a search API server & index
- Go to Configuration > Search API.
- Click the "Add server" button and configure the Server.
- Click the "Add index" button and configure the Index.
- Go to Configuration > Search API > Your index > Fields
- Add fields like Body, Title, tags, Authored on ...etc
- For the fields that you only want to find them by word-part use "Fulltext Ngram" and save changes.
- Go to Configuration > Search API > Your index > View and click "Index now" (Depending on your content; this may take a while)
Step 3. Create a view page (Content index)
- Go to Structure > Views and add a view to show data from your index.
- Add filter criteria "Fulltext search" and set "Searched fields" and Parse mode to be "Direct query",
Now, your website visitors can enjoy a smooth searching experience without being frustrated with the search results. What other solutions or experiences did you have with Apache Solr with regards to optimizing search experiences?
I look forward to reading your opinions and recommendations in the comments section below.