Advanced Site Search Capabilities with Relevanssi

searching with a magnifying glass

Executive Summary

Site search — that lets users search for content on a website — is commonly requested, yet is hard to do well. We discuss the Relevanssi search plug-in and how it helps to deliver relevant results and enables a customized user experience on a WordPress site.

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


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.

Related Insights

How to Display WordPress Posts in a dynamic grid layout

We've made building dynamic grids on WordPress easy!

Ankit Patil


WordPress Maintenance and Optimization Checklist For 2023

Keep your WordPress website optiized with a complete maintenance checklist.

Ashwin Thapliyal


20 Fascinating Facts About WordPress that you might not know

The leading CMS in the world has some secrets that are still unknown.

Ashwin Thapliyal


Subscribe to our newsletter