When building sites, you occasionally need to create small blocks of content that can be…
WordPress comes with search right out of the box, which is great. But it sorts results by dates, weights all content equally, can easily miss custom fields and other data, and doesn’t always return the most relevant results. A couple of years ago, SearchWP came along to pick up this slack. Since then, it has been the best search engine solution for WordPress. Let’s dive in.
What’s It Do?
SearchWP takes the place of your default WordPress search engine automatically and re-indexes your WordPress content to output the most relevant search results for users first. It allows you to customize the weight given to certain content types (title, excerpt, tags, etc.) based on post type, including custom post types. The plugin also supports keyword stemming, and includes the ability to read PDF content and include these documents in results, as well as support for custom field data built right in. And it integrates just fine with Multisite and bbPress installations.
You can also set up as many search engines as you like. Supplemental search engines, with content type weights and exclusions different from the default search engine, can be created and inserted anywhere in your template files with a little bit of PHP, and statistics on how your search is performing is provided for you in easy to access logs.
SearchWP is designed to work pretty much out of the box, so it only contains a stripped down set of options. Everything else happens more or less automatically so you can improve your search results quickly, though a full API gives developers the ability to hook into the plugin and tweak its feature set.
How’s It Work?
Upon activation, SearchWP will begin to index your site without you touching a thing. The first step is to actually make the plugin active. If you go to Settings -> SearchWP you will see an option to “Activate License.” Click on this and enter the license information you received with the purchase of your plugin to connect to your WordPress install.
When your site is being indexed, you will see a progress bar at the top of the settings page, letting you know how much of your site has been indexed. The time this takes shouldn’t be more than a few minutes, but it depends on how much content is on your site.
Below this, you will see a list of search options. On the left side of the page, you will see a listing of post types on your site. This includes the default post types, post, page, and media, but also any custom post types you have installed. Relevance in search results can be adjusted on a post type basis, simply by flipping through these tabs.
The majority of your customization comes from the search weight of various content types. Next to each content type listed, there will be a number designating how it should be prioritized in search results. The higher the number assigned, the heavier it will be prioritized. Title and Excerpt, for instance, have a higher number by default because they are typically where the most important information is displayed. Content Types with a weight of “0” will be excluded from search results. However, make sure to run through the defaults and change the settings to match your site’s content. Chances are, you’ll have different priorities than the default settings.
You’ll also see an option to “Add Custom Fields.” Clicking on this will give you a drop-down menu with a list of custom fields used on your site. Select any from the menu to assign it a weight. If you have important content keywords hidden in custom fields, this is a great way to surface that text in search results without sacrificing the other content on the side.
On the right-hand side, you’ll see the option to exclude certain IDs, categories, tags or formats. Simply insert the IDs of specific posts, or the slugs of categories, tags or format types to omit them completely from any search results, if you have a hidden page, for instance. You’ll also see the option to “Attribute Search Results To.” The last option is to “Use Keyword Stem.” Keyword stemming allows the root of a word to be used to produce broader results. So if you a user were to search for “run” then the results “runner” and “running” would be included as well. To use keyword stemming, simply check the box. When you are all finished, you can click the “Save Changes” button at the bottom of the page.
There’s one other feature worth mentioning here. If you select the “Media” post type from the settings, you will see an option to “Include PDF Content.” What this will do is include the actual text from and links to PDF documents in your search results, assuming that your PDF has parseable text. If you have a site with a lot of PDFs, this is certainly worth checking off.
On the settings page, you will also see the Supplemental Search Engines section. This allows you to create any number of secondary search engines with its own customizations, to find segmented results apart from the main index. If you, for instance, would like a search engine that only searches through a specific post type, you can create a supplemental search engine. The settings for these search engines are the same at the top, but after you create one, you will see a title and a slug next to it. Pay attention to this slug, as this is what you need in order to insert the search engine into your files. You can use a little bit of PHP in order to include a supplemental search engine in your templates. There’s plenty of more information in the documentation.
One of the newer features of SearchWP is statistics for each one of the search engines that you create. If you click on the “Statistics” link next to a search engine, you will be brought to a page which has some analytics detailing how people are using search on your site. It has a list of activity in the last 30 days, alongside top queries from the current day and week. You will also see a list of failed searches, searches that did not return any results. Using this data, you can make informed decisions about what to do with your search engine next, or what kind of content you can add to the site.
The plugin also features a few hooks to change its functionality. There’s documentation on the Developer API, but for the sake of example, let’s say you wanted to include relevance based searches in your admin as well as on the front-end (when you are searching through posts and pages). Simply open up your functions.php file and insert the following code:
function mySearchWPInAdmin() { return true; } add_filter( 'searchwp_in_admin', 'mySearchWPInAdmin' );
This will include SearchWP functionality in your back-end. There are several other filters to take advantage of, as well as two actions, which can be found in the Developer API documentation. Basically, if it has to do with search, SearchWP has you covered.
Special Offer
SearchWP was one of the first plugins I reviewed for this site, but I’ve updated this review to highlight a brand new offer from the team. From now until February 15, get 25% off of any SearchWP license by using the special code “TIDYREPOROCKS”. That’s valid for any license on the site. So, go make search better.
Costs, Caveats, Etc.
SearchWP is a paid plugin and has several license options available. License purchases include support and updates for a year and downloadable extensions. Extensions allow you to build out the functionality of SearchWP in a modular way so that the main plugin is merely expanded instead of altered. Extensions exist for bbPress integration, fuzzy search, term prioritization, specific keyword exclusion, FacetWP integration, and a whole lot more.
Support is handled in the plugin’s forums and is available for paid customers.