Search

Better WordPress Search Mechanism with Relevanssi

If you’ve ever had the chance to use WordPress’s built-in search functionality to search for content on your site, I assume you’ve noticed that it’s an area where WordPress falls short.

When a visitor arrives at your site, performs a search, and doesn’t easily find what they’re looking for, it’s reasonable to assume they might leave your site and search elsewhere.

Given that WordPress’s standard search mechanism lacks in effectiveness, there’s a high likelihood that you’re missing out on potential customers every time someone searches your WordPress site. If not, you’re missing the opportunity to present them with the content they desire.

However, there’s a plugin that improves the search functionality on your WordPress sites for your users, and its usage involves installing a plugin and configuring a few settings. The plugin is called Relevanssi – A Better Search, and in this post, we will explore the features that Relevanssi offers and see how to use it.

Better Search with Relevanssi

There’s a free version of the plugin available for download from the WordPress plugin repository. However, in this post, we will review the Premium version of the plugin, which is available for purchase from the developer’s website.

Even using the free version of the plugin provides excellent results, so if you don’t have specific requirements, you can rely on it without needing to buy the Premium version. However, if you do decide to purchase the Premium version, the SAVVY coupon code should give you a 20% discount.

In a few words, the purpose of the plugin is to present your users with more relevant search results for specific words or phrases on your WordPress site. Additionally, the plugin gives you much more control over how search results are displayed and presented on your site.

To provide these capabilities, the plugin includes several features and capabilities that are not found in WordPress’s basic search mechanism:

  • Searching in comments and author names
  • Searching in categories, tags, or any other taxonomy
  • Searching in meta fields – Custom Fields
  • Searching within content contained in shortcodes
  • Searching in excerpts
  • Searching in user profiles
  • Displaying “Did you mean…” in a Google-style
  • Highlighting relevant results
  • Option to filter private content tailored for pages, tags, and categories
  • Using logical expressions for search
  • Choosing the “weight” for each content type

Full List of Relevanssi Plugin Features

We will present a table that differentiates between WordPress’s standard search and the free and Premium versions of the Relevanssi plugin.

Feature WordPress search Relevanssi Free Relevanssi Premium
Easy to install X X X
Index is updated automatically X X X
Newest posts first X X X
Best results first X X X
Search posts and pages X X X
Search comments and comment authors X X
Search post categories, tags and custom taxonomies X X
Search custom fields X X
Search shortcode content X X
Search post excerpts X X
Include user profiles in search results X
Index PDF content X
Include taxonomy terms in search results X
Search arbitrary MySQL columns in wp_posts X
Show “Did you mean” suggestions x X
Search results show and highlight the matches X X
Posts highlight the search term matches X X
Exclude posts, pages, tags or categories from search X X
Use fuzzy matching to make getting hits easier X X
Choose between AND and OR operator in search X X
Change the operator on the fly if necessary X
Use the NOT operator to exclude search terms X
Adjust the weight of post content, titles and comments X X
Adjust weights by post type X
Adjust weights by taxonomy X
Adjust weights by post date X
Adjust weights manually with a filter hook X X
Log user queries X X
Use stop words to make search better X X
Expand queries with synonyms X X
WPML and Polylang integration X X
WordPress Multisite support * X
Throttling to make searches perform better on big databases X X
Export / import settings X
WP CLI support X
Guaranteed support from Mikko X
Have sticky posts in searches based on search term X

 

As you can see, one of the advantages of the Relevanssi plugin compared to the standard WordPress search is the option to search in all types of content on your site. Through a bit of customization, you can make the Relevanssi plugin search within the metadata fields created in the Advanced Custom Fields that we all love. Without the ability to search in these types of content, it’s reasonable to assume that users on your site won’t be able to find the most relevant result for the term they were searching for.

Another very important feature of the plugin is the ability to assign weight to each type of content and its elements, so that the same content will be more dominant and appear earlier in search results. This option can promote a specific post in ranking and attract more visitors to it.

This can be achieved by assigning a higher weight to an element where the searched term exists, such as the post title, post body, or comments. The weight can even be based on the publication time of the post, so that readers receive the most up-to-date content in search results.

It can be said that the Relevanssi plugin covers everything you’ve ever wanted in the WordPress search mechanism and that didn’t exist before. The Premium version of the plugin even allows you to index PDF files that you’ve uploaded to your site’s media library. This is a very interesting option for many WordPress sites.

The Relevanssi plugin also enhances search capabilities in WooCommerce and virtual stores built with WordPress, allowing for SKU (Stock Keeping Unit) search and displaying more relevant results for potential buyers, increasing the likelihood that the visitor will find the product they are interested in purchasing.

Settings and Usage of Relevanssi

relevanssi-wordpress-plugin
After you’ve downloaded and installed the plugin (in this case, the Premium version, but the guide is relevant to the free version as well), go to the plugin’s settings under Settings > Relevanssi. Go to the Indexing tab and select the types of content you want to index under Indexing Options.

Note that you shouldn’t expect to see search results on your site immediately after activating the plugin, as the index needs to be built. You won’t see results if you perform a search on your site before the index is built.

Indexing Settings

We won’t go into too much detail, but here are some of the options in this section. Note that you’re saving options after each change in a specific window:

relevanssi-indexing-options

Post Types – All types of content on your site will appear here. You need to specify which content type you want to index, whether it’s pages, posts, file attachments, or any other type of content. As you can see in the Savvy blog, I choose to index only posts and snippets on the site.

Taxonomies – All taxonomies on your site will appear here. Categories, tags, or any other taxonomy that exists on your site and you want to appear in search results. For example, if you select post_tags to index tags, when a user searches for a word that matches one of the tags, it will appear in search results. I don’t choose to index any of the taxonomies on this blog.

Comments – This option allows content within your comments to be included in the index, so that the text of comments contributes to the search results.

Custom Fields – In this section, you can choose whether to index the custom fields existing on your site. This is also where Premium users can choose to include fields from the Advanced Custom Fields plugin and even repeater fields.

Expand Shortcodes – If you use shortcodes in the post content on your WordPress site, this option ensures that those shortcodes are indexed as well (or what they generate will be more accurate). For a WordPress site built with a Page Builder, which often uses shortcodes, it might be a good idea to select this option.

Two Tips for WooCommerce sites – Note that if your site is an e-commerce or virtual store using WooCommerce, you should not select Expand Shortcodes, as WooCommerce includes shortcodes and might not work well with the Relevanssi plugin (when this option is active).

However, if you want to index SKUs, you can add the metadata field name of the SKU to the Custom Fields section mentioned earlier. This is how it should look:

WooCommerce SKU Relevanssi

Another tip for WooCommerce and Relevanssi – if your SKUs contain hyphens (-), go to the bottom of the page and click on Advanced Settings, then select the option Hyphens and dashes to Remove. This way, Relevanssi will ignore hyphens in the SKU and provide accurate results for those who search with or without hyphens.

Search Settings

Let’s go over a few search settings:
Default Operator – You can choose whether the search will be performed based on the entire phrase or if posts with even one word from the phrase will appear in search results.

For example, if I search for “site speed,” I’ll see search results that contain the word “site” or “speed.” I prefer to show results for each word rather than the exact phrase in the Savvy blog. Of course, if the exact phrase exists in one of the posts, that post will have priority and appear before a post where only one of the words exists.

relevanssi-operator

The Default Order setting should be left on Relevance…

Keyword Matching – This setting determines whether Relevanssi will display search results where only part of the letters of the searched word appear. For example, if you searched for “comme”, you will see search results that include the word “comments.” In my case, I chose to show these results only if there are no exact matches for the word or phrase. This is how it looks:
relevanssi-keyword matching

Weights – Naturally, the weight of each type of content/element also has an impact on the order in which search results will appear. In this section, you can choose the relative weight for each type of content, taxonomy, pages, as well as components of the same post/page, such as:

You also have the option to give priority or a bonus to recently published items (Recent Posts) in this section. Here is an image illustrating how I chose the weights for each of these in Savvy Blog:


relevanssi-weights

Note that I assigned a higher weight to titles than to the body of the post, and that post content type has a higher weight than snippet content type.

Exclude From Search – When you create custom post types, you can define that the post type will not appear in the standard WordPress search results by adding the parameter exclude_from_search set to true.

Enabling this option fulfills the requirement, and the content type will not be indexed by Relevanssi even if it is marked in the Relevanssi Indexing settings mentioned above.

Post Exclusion – You can enter a list of page IDs that will not be included in the Relevanssi index. Use commas to separate the IDs…

We won’t go beyond these settings in this section, you are welcome to read the notes next to each of the options. The plugin developer explains very nicely what each option is…

Building the Relevanssi Index

Go back to the Indexing screen and click on Build The Index. Let the plugin do its job, and when the process is complete, go to your site and perform a search for any phrase.
index-building-relevanssi

At this stage, you should see results according to the choices in the plugin settings, sorted according to the relative weight you’ve set.

There are many additional options in the plugin that allow you to make various changes and customize the Relevanssi plugin according to your needs.

There are also hooks, actions, and filters that developers among you will find very helpful. There is the option to add synonyms, highlight words in search results, and many more options…

If you want more information about the plugin, you are welcome to take a look at the official Relevanssi documentation to get an idea of its additional capabilities.

In Conclusion

Whether you are installing the free version of the Relevanssi plugin or the premium version, the plugin will certainly improve the search results on your WordPress site. This action will enhance the user experience by displaying more relevant content and preventing visitors from searching for answers on another blog – thus increasing the exposure of your posts.

In any case, even if you don’t go through all the plugin settings and only do what we mentioned in this guide, you will receive excellent results…. 🙂

Roee Yossef
Roee Yossef

I develop websites & custom WordPress themes by design. I love typography, colors & everything between, and aim to provide high performance, seo optimized websites with a clean & semantic code.

0 Comments...

Leave a Comment

Quick Navigation

Up!
Blog