Better Search v4.4.0: Feature Manager, Did You Mean, and Search Redirects

Better Search loaded every optional feature whether you used it or not. Widgets, shortcodes, block patterns, live search, the WP-CLI commands: all of them registered their hooks on every request, even on a site that only wanted results ranked by relevance. I’ve been meaning to fix this for a while.

4.4.0 adds a Feature Manager so you can turn off what you don’t use, plus two Pro additions that come out of the same feedback: “Did you mean” suggestions and search redirects.

Better Search v4.4

Feature Manager

There’s a new Features tab in Better Search settings. Every optional feature gets a toggle.

Features tab in Better Search v4.4

In the free plugin, it covers the classic widgets, the shortcodes, the block patterns, and live search. Pro adds fuzzy search, custom index tables, multisite search, the network admin pages, the dashboard chart drill-down, the WP-CLI commands, and the two tools I’ll cover below.

Turn one off, and the plugin stops loading that feature’s code. No hooks, no assets, nothing on the front end.

Settings that belong to a feature you’ve turned off stay where they are. They’re marked as having no effect while the feature is off, so a setting doesn’t vanish out from under you when you flip a toggle. Every toggle starts out matching what your site already does, so updating to 4.4.0 changes nothing until you go and turn something off yourself.

Settings search

The settings page has grown a lot over the years, and finding one specific option meant scanning tab after tab. 4.4.0 puts a search box in the tab bar itself.

Search settings in Better Search v4.4

It matches on option labels, their descriptions, and the underlying field names, so you’ll find a setting even when you only remember what it does. Matches are highlighted in place, and each tab carries a count of how many it holds, which saves you from clicking through the ones with none.

“Did you mean” suggestions (Pro)

This follows the Fuzzy Search feature that I implemented a few versions back. But, this could also be a bit heavy. So, not everyone would want to use this.

Better Search Pro now offers spelling suggestions for zero-result searches. Someone searches for “wordpres” instead of “wordpress” and gets nothing back. That’s a lost visitor, not just a typo.

Did you mean search suggestions example

There are two modes. Suggest shows a “Did you mean” link the visitor can click. Auto-correct rewrites the query automatically and shows results for the corrected term. Which one fits depends on how much you trust the correction and how forgiving your content is of a wrong guess.

Suggestions come from your own site, and the sources are tried in order. Better Search checks your search log first, since a term other visitors have already searched several times is the likeliest correction. Three searches by default, and you can raise or lower that on the Search tab.

If nothing matches there, it falls back to a dictionary table, wp_bsearch_dictionary, built from your published post titles and public taxonomy term names. That table is rebuilt twice a day on cron.

Only when both come up empty does PHP’s enchant extension get a look, and only if you turn it on. Enchant knows English; it doesn’t know your content, so “wordpres” corrects fine, but your product names won’t. That’s why it’s the last resort and not the first.

The feature is off by default. Turn it on from the Features tab, then set the mode and the thresholds on the Search tab. The documentation covers installing enchant, the template tags for theme integration, and the filters for tuning how the matching behaves.

Search redirects (Pro)

Also new in Pro: search redirects, on their own Redirects tab. Each rule takes a comma-separated list of keywords and sends the visitor to a post, a page, or a URL instead of a results page.

Better Search Redirect Rules

Exact matches the whole search phrase. Contains matches when the keyword turns up anywhere inside it. Either way, the comparison ignores case, surrounding spaces, and repeated spaces, and every exact rule is checked before any contains rule, so a specific rule always beats a broad one.

Rules are 302 by default. Browsers cache permanent redirects aggressively, and a 301 you regret is hard to take back, so switch a rule over only once you’re sure it’s permanent.

This is useful for the searches you see over and over. If your visitors keep searching for “support” and you’d rather send them straight to your support page than to a results list, you can now do that in a couple of clicks instead of writing a custom redirect rule.

Redirected searches are still recorded in your search statistics. The JavaScript tracker never runs on a request that redirects, so the count is written server-side instead. Add bsearch_no_redirect=1 to a search URL to see the results page anyway, which is how you check a rule without switching it off. That works for administrators only.

Off-site destinations work too. Each redirect allows only its own destination host, and only for the duration of that one redirect. If you’d rather rule them out completely, add this:

add_filter( 'bsearch_allow_offsite_redirect', '__return_false' );

On a multisite network, I would. Every subsite administrator can edit these rules, and on a subdirectory network a redirect to another subsite counts as the same host, so this filter won’t stop that one.

Bug fixes

Saving settings in the free plugin could wipe out your Pro values. A Pro-only setting is rendered disabled in the free version, but its hidden companion field wasn’t, so saving the page wrote an “off” value over whatever Pro had stored. Fields inside a disabled Pro repeater were still editable for the same reason. Those keys are now left untouched, so your configuration survives a switch between the two plugins.

A required field inside a collapsed repeater row blocked saving with no explanation. The browser won’t report a validation error on a control it can’t show you, so the form just stopped. Required fields in repeaters are now checked when the settings are saved, and the problem is reported back to you.

The Pro setup wizard renumbered its steps mid-run. The Index Custom Tables step appeared or disappeared depending on your settings, which shifted every step after it while you were working through the wizard. The step is now always shown, with a notice explaining why indexing isn’t available when it isn’t.

Other fixes in this release:

  • Fixed settings page layout and field rendering issues.
  • Fixed database checks not restoring the previous error display state.
  • Fixed highlighting fallback behavior for queries containing an unclosed quote.

Also in this release

I added a bsearch_pre_index_content_parts filter so you can append extra text to what gets stored in the custom search tables. It receives the raw post content before block and shortcode processing, which is the whole point: if a shortcode holds text your visitors search for and processing strips that text out before it reaches the index, this is where you put it back.

FULLTEXT index names are now consolidated on the shared wz_ names, so an index on the same columns created by a sibling WebberZone plugin counts for Better Search instead of a near duplicate sitting on wp_posts. Better Search still recognizes its own older bsearch_ index names, and the excerpt index created by Contextual Related Posts, so nothing gets rebuilt that doesn’t need to be. Missing indexes are recreated on their own the next time you load an admin page.

Pro also registers a FULLTEXT index on post_excerpt now. That’s an ALTER TABLE on wp_posts, and on a site with a lot of posts it takes a while, so run this update at a quiet time rather than at your busiest.

The bundled Settings API is updated to version 2.10.1 with refreshed admin assets.

Upgrade notes

  1. Update Better Search (and Better Search Pro, if you use it) from your WordPress dashboard. On Pro, a FULLTEXT index is added to post_excerpt, so pick a quiet moment if your site is large.
  2. Check the new Features tab and turn off anything you don’t use.
  3. If you’re on Pro and want “Did you mean”, turn it on from the Features tab, then choose Suggest or Auto-correct on the Search tab. It’s off by default.
  4. Redirect rules live on the new Redirects tab.

Keep on publishing! Let your users keep on searching.

Leave a Reply

Your email address will not be published. Required fields are marked *