Highlighting search results
Blog

How to highlight search results in Search API Solr View in Drupal 8

In Search API, there is a field for a search excerpt that you can use on field views to highlight search results. In this article, I’m going to show you how to enable excerpt and set it using views. Here I’m assuming that you have already set the Search API module and has a Search API Solr view.

Follow the steps:

Go to Manage -> Configuration -> Search and Metadata -> Search API.

In your search API index ‘processors’ tab, enable Highlight Processor as shown below.

search API index ‘processors’ tab

In the processor settings tab, check “Create excerpt” field. You can also set the fields to generate excerpt.

Create excerpt field

Save the configurations and re-index all the data so that the added configuration will take effect.

Edit your Search API Solr view. You can display highlighted results only if your view is displaying fields. However, if you need to build a custom view based search_api search that renders entities instead of using fields, the excerpt info stays hidden in the view result array.

custom view based search_api

 

Click on Add fields and select the excerpt field

Create excerpt field

You can add other fields along with Excerpt field as per your requirements. Save the view and check the search results, You will be able to see highlighted output!! 

Hope now you know how to highlight search results in Search API Solr View for Drupal 8 website. If you have any suggestions or queries please comment below let me try to answer.