admin-plugins author calendar category facebook post rss search twitter

TIDY REPO

The best and most reliable WordPress plugins

Relevanssi

Plugin Author: Mikko Saari

Jay Hoffmann

September 4, 2013

Navigation, Page

If you’re like me, you’re not often happy with WordPress’ search functionality right out of the box. I don’t know if I completely understand why, but it sometimes feels improperly indexed and rigid. You could use a third-party service like Google to supplement your page searches, or you could use Relevanssi to improve WordPress’ built-in search.

What’s It Do?

Relevanssi hooks into WordPress’ built in search functionality, improves its indexing and search results, and gives you the ability to tweak its output. It basically replaces search on your WordPress site with an even better version.

You also won’t have to change anything on your site. Anywhere that a search form exists on your site will be automatically improved, so it’s pretty easy to set up.

How’s It Work?

When you install and activate Relevanssi you will be prompted to visit the settings page to get everything working properly. Go to Settings -> Relevanssi to get started.

At the top you’ll see three big buttons, Save Options, Build the Index and Continue Indexing, with a long list of options underneath it. You’ll need to run the build process in order to get the plugin working properly, but let’s start with the settings categories for now.

Relevanssi1

Basic Options is exactly what it sounds like, simple tweaks to toggle on and off. You can limit how many search results are returned and change the order of search results. You can also turn on the Relevanssi in the admin section of your site, and enable “fuzzy matching” which will return search results with similar terms if an exact match cannot be found. In general, I tend to leave everything at it’s default, but lowering the search result limit to 100 or so is a generally good idea for performance reasons.

Weights has to do with how different content pieces are prioritized in search results. You can change the weight of post titles, comment text, tags and categories, on a scale from 0 to 5. If you give a category a weight of 0, they won’t be included in search, a 1 means they will be weighted evenly, and anything above a 1 means they will be given priority in your results. It is probably worth it, for instance, to give comment text a weight of 0, while keeping Post Title at a number higher then 1 so that posts and pages are returned based on the actual content of the post and it’s title, rather then skewed by random posts in the comments.

Relevanssi2

Logs is fairly simple and lets you keep logs of queries your users have searched for.

Exclusions and Restrictions allows you to either include only certain categories and tags. The first box is “Restrict Search to these categories and tags.” If you enter in a list of category/tag IDs into this box, then the search will only return results from these taxonomies. Below this is the option to exclude certain categories and tags, or specific posts and pages. Once again, simply enter Post IDs to exclude. The last option is whether or not to respect the “exclude_from_search” custom post type option. Unless you have a very good reason to do otherwise, I would keep this box checked.

Custom Excerpts/Snippets and Search Hit Highlighting allow you to customize the output of search results. By default, the plugin will display the title of the post with an excerpt that includes the terms from a users queries bolded for emphasis, similar to Google search results. You can change this around to assign a specific class to bolded elements, change the length of the snippet, customize the look of the excerpt, or turn off custom snippets altogether.

Once you are finished tweaking the plugin, click Save the Options to make the changes.

Next, you need to build the index. The Indexing Options section allows you to chose exactly what you would like to include in the index. It’s fairly straghtforward, but you can select which post types (post, pages, attachments, custom post types) to include in your search index, which taxonomies (categories, tags, etc.) to include and whether to include author pages and excerpts. Keeping the index on its default settings usually does the trick, but make sure to comb through and make sure that you include everything you want to appear in search results. Certain custom post types and custom fields may not be included by default for instance, and the attachment post type should almost never be included.

Relevanssi3

Below this is the ability to turn Caching on and off. If you are already using a caching plugin, there’s no need to do this, but otherwise it may be a good idea to turn it on.

Finally, you can define Synonyms and Stopwords to enhance the search experience. You can add similar words to be cross-referenced in the Synonyms section by using a “key=value” syntax. For instance, “development=coding” or “apple=orange.” If somebody searches my site for development, then they will get results featuring the word coding in it as well. Stopwords are common words that shouldn’t be included in search results, like conjunctions or numbers. By default, there will be a comprehensive list of stopwords, but if you’d like to add any you can add them here.

When you’re all finished setting your indexing options, hit the Build the Index button at the top of the page. Relevanssi will then crawl through your pages and build an index of terms located throughout your content.

The plugin will start working automatically. Anywhere that you have a search field on your site will return results that Relevanssi has indexed, using the WordPress search function.

<?php get_search_form( $echo ); ?>

Costs, Caveats, Etc.

Relevanssi is free to use, but there is a premium version with extra features, like mutlisite support and deeper indexing of content as well as priority support. It’s updated frequently and keeps up with the pace of WordPress.

If you are having a problem, the first thing to do is check out the most important debugging trick. Basically if there is a query_posts() call on your search results page (which you shouldn’t be using anyway), then Relevanssi might not work. Beyond that, check the Knowledge Base for any questions you might have. And if all else fails, try the support forums and you’ll usually get a response.

Resources

Download Relevanssi Now!

Did you like this post?

  • http://www.mikkosaari.fi/ Mikko Saari

    As a general rule I would recommend not using the caching feature in Relevanssi. It is useful only in cases when you know you will be seeing lots and lots of repeated searches. In most cases it’ll just eat up lots of database space.

    Thanks for the good article about Relevanssi!

  • dev

    this plugin is not working with implicit theme. Any solution…???

About this Plugin
Get the latest

Signup for our newsletter to get plugin tips, and see what's coming down the pipe.

Plugin Categories