Advanced Site Search Capabilities with Relevanssi

searching with a magnifying glass

Introduction

The search features in WordPress CMS involve limitations like no prioritization of content type for search results, inability to search for attachments, and no customization of the interface. These limitations can be tackled with different plugins. Relavanssi is one such plugin that can offer the above features and is integrated with the FacetWP plugin to achieve faceted search. Read further to know about the above-mentioned plugins and the integration process in detail.

Why Relevanssi?

The search feature that ships with the WordPress CMS is quite limited. For eg. it doesn’t search attachments, it cannot prioritize which content to show first and it doesn’t permit you to customize the look-feel of the search results. To get around these limitations, there is a robust marketplace for WordPress search plugins such as SearchWP, Jetpack Search and others. Relevanssi is widely considered the leader in this space.

The Use case

The client is an insurance company and had the following types of content (all of which were modeled as Custom Posts):

  • Employees
  • Experts
  • Insight Articles that were written by Experts
  • News Publications that mentioned Experts
  • 3rd Party News Mentions
  • Leadership Team
  • Specialty Products
  • Practice Areas
  • Offices

In addition to these, there were regular WordPress entities such as:

  • Pages
  • Media
  • PDFs
typical search result page

When a user searched on the site, there were several requirements:

  • We had to show relevant content from the various post types along with the # of results in each category
  • There were different weights for these content types. For eg. Specialties were weighted more than regular pages and were required to show up higher in the search results.
  • “Faceted” search was requested. As the user clicked on different categories, we had to filter the results accordingly. The users could also remove their selections to go back to earlier states of the search parameters (as shown above)
  • We had to exclude certain post types in the search results
  • The user could sort the search results alphabetically or chronologically
  • We had to highlight the search term within the search results.
  • We had to enable synonyms. For example, when the user searched for say “Commercial Property”, we were supposed to search for “Real Estate” as well.
  • Finally, the user could filter the search results based on the publish date (Past week, Past month etc)

Getting Started with Relevanssi

After installing the Relevanssi plugin, you can navigate to the dashboard :

relevanssi wordpress plugin overview screen

After doing the basic setup, you can index all the content. There are quite a few options here, in terms of what you want to include in the search vs. not.

relevanssi plugin settings

As mentioned in the use case, the client wanted certain post types to show up higher. (For eg. specialties should be weighted higher than say insight articles). To achieve this in Relevanssi, you can navigate to the “Searching” tab. Here you will be able to assign weights as required:

relevanssi wordpress plugin advance settings

There are many other options that allow you to tune your search results carefully.

relevanssi plugin extra settings

Finally, you can configure synonyms for search terms as well

relevanssi word plugin search synonyms feature screen

Combining Relevanssi with Faceted Search

The client’s requirements needed for us to show Relevanssi search results in a Faceted search mode.

combining relevanssi with faceted search

To achieve this, we used the FacetWP plugin along with Relevanssi. For our detailed article on how to use FacetWP, go here.

Install FacetWP and when you go to create a “New Facet”, select “Search” as the Facet Type

facetwp wordpress plugin settings

And then select Relevanssi as the Search Engine

adding relevanssi in facetwp

Now configure the query to point to the different post types that need to be searched for, and also any posts that shouldn’t be included in the search. (see below)

configuring relevanssi in facetwp

At this stage, you can define how you want the query results to show up:

query result template on facetwp wordpress plugin

These steps will now result in the search page showing up as desired:

facet search result page

The final step involved building the “Sort By” functionality. We built a simple PHP function to enable this capability as shown below:

php code for sorting facetwp search result page

Summary:

Site search — that lets users search for content on a website — is commonly requested, yet is hard to do well. We discussed the Relevanssi search plug-in and how it helps to deliver relevant results and enables a customized user experience on a WordPress site. We also reviewed how to integrate it with FacetWP to enable faceted display of the search results.

No items found.

Related Insights

Design and Operations of Complex Data Feeds in WordPress

In this post, we discuss how to design for importing complex data feeds in WordPress. Since these feeds need to be imported on a regular basis, we also show how to design and operate these processes. We will implement these workflows using the WP All Import Pro plugin.

Vinod Pabba

WordPress

Yoast vs. Rank Math : SEO comparison

SEO is essential for attracting customers to your website. Although good content is fundamental to this, there are several technical optimizations to your website that will go a long way to improving your SEO scores. If you run your site on WordPress, it is quite important to use good plugins to assist with your SEO. In this post, we explore Rank Math — a newcomer to the WordPress SEO world and also contrast it with Yoast, a leader in this space.

Saichand

WordPress

Subscribe to our newsletter