Ahosting Logo
Knowledge Base

How to Improve WooCommerce Search and Filters

Search and filters serve two different customersSearchFiltersThe customerknows what they wantis choosing between optionsDefault behaviourmatches words in title and contentoften not present at allWhat it missesSKUs, attributes, variationsn/aCostdefault search is also a database loaddepends on implementationDefault shop search fails exactly the customers who had already decided, which are the ones you least want to lose.

Shop search is where customers with intent go when browsing has failed them. It is also, in a default installation, one of the weakest parts of the site, and one of the heaviest.

Why the default search is poor

WordPress search matches words in the title and content. It does not know about SKUs, attributes, variations or categories, and it does not handle a near-miss.

So a customer searching for a product code finds nothing, a plural finds nothing, and a slight misspelling finds nothing, while the product sits in the catalogue.

That is not a small gap. Someone typing a specific product name has already decided; returning "no results" to them is the most expensive failure a shop makes.

It is also expensive to run

A search query scans the posts table and cannot be served from cache, because every query is different.

On a large catalogue that is a slow query on every search, and search traffic tends to arrive in bursts. A shop that is fine while browsing can struggle when a campaign sends people straight to the search box. There is more on the wider picture in WooCommerce Speed Optimization Tips.

What a search plugin adds

Three things worth having, and they are the reason to use one rather than tuning the default.

Searching the right fields: SKU, attributes, categories, tags, and custom fields, not just the description.

Tolerance: partial words, plurals, and small misspellings still find the product.

Relevance. A title match ranks above a passing mention in a description.

Check whether it also excludes out-of-stock products, or ranks them lower. Returning something the customer cannot buy is only marginally better than returning nothing.

Index-based search takes the load off

The heavier plugins build their own index rather than querying the posts table each time, and some offload it to a separate service.

That changes search from a slow database query into a fast lookup, which matters on a large catalogue and matters less on a few hundred products.

The trade is another moving part: an index that can fall out of date, and a service that can be unavailable. Make sure the index rebuilds when products change, and check what happens when the service is down. A shop whose search fails closed is worse than one with slow search.

Filters and search are different jobs

Search is for someone who knows what they want. Filters are for someone narrowing a set.

Filters work on attributes, which means the attributes have to be global rather than per-product: only global attributes can drive layered navigation, and rebuilding a catalogue to fix that later is tedious. For the distinction, see How to Set Up Product Variations in WooCommerce.

Keep the filter set short. Six filters with four options each is more combinations than anyone will explore, and each one is a URL serving the same products, which needs canonical handling. There is more in How to Structure WooCommerce Categories and Navigation.

Show counts, and never show a dead end

A filter option leading to zero products should say so before it is clicked, or be hidden.

Counts beside each option do that, and they also tell the customer where the stock is. Without them, filtering is a series of guesses that sometimes empties the page.

When a combination genuinely has no results, say so and offer a way back; a suggestion, the nearest match, or a link that clears one filter rather than all of them.

Write the no-results page properly

The most valuable page in this article, and usually the emptiest.

Somebody searched, which means they wanted something specific. "No products found" ends the visit.

Offer the search box again with their term still in it, a few popular products, a link to the full catalogue, and a way to ask you. On a shop that regularly gets searches for things it does not sell, that page is a product research list as well.

Read what people search for

Log the search terms, and the ones returning nothing especially.

Three patterns appear, and each has a different action. Terms for products you sell under another name: add that word to the product. Terms for products you do not stock: a demand signal. And misspellings of your own product names. A search plugin that tolerates them, or a synonym.

Most shops never look at this, and it is the cheapest customer research available. How to Read WooCommerce Analytics and Reports deals with the rest of the numbers.

Test it as a customer

Search for a product by its exact name, by a partial name, by its SKU, with a plural, and with one letter wrong.

Then do the same on a phone, where the search box is often hidden behind an icon and the results are harder to scan.

Five searches, and they tell you more about your shop's search than any setting page does.

Find out what the search is costing

Search on a large catalogue is one of the few things that cannot be cached and runs against the database every time.

awk '$7 ~ /\?s=|\/search/ {print $7}' ~/logs/example.com | wc -l
mysql -e "SHOW FULL PROCESSLIST" | grep -ci 'select.*like' 2>/dev/null
wp db query "SELECT COUNT(*) FROM wp_posts WHERE post_type='product' AND post_status='publish';"

A search that scans product titles and descriptions with a leading wildcard cannot use an index, so the cost grows with the catalogue rather than staying flat.

The combination that causes trouble is a large catalogue and a visible search box, since every visitor who uses it triggers the most expensive query the site can run. That is the case where moving search to a dedicated index pays for itself rather than being an improvement.

Read what customers actually type

The search log is the most direct statement of demand a shop receives, and almost nobody reads it.

awk -F'[?&]' '{for(i=1;i<=NF;i++) if($i ~ /^s=/) print substr($i,3)}' ~/logs/example.com \
  | sed 's/+/ /g' | sort | uniq -c | sort -rn | head -20

Three things surface. Terms that return nothing, which are either products you should stock or words your catalogue does not use. Repeated misspellings, which need synonyms. And demand for a category you have not created.

Each of those is a change you can make this week, informed by what customers asked for rather than by what you assume they want.

Filters have to reflect what exists

A filter that offers a choice leading to nothing is worse than not offering it, because the customer concludes you do not stock what they wanted.

wp db query "SELECT t.name, COUNT(tr.object_id) AS adet
  FROM wp_terms t
  JOIN wp_term_taxonomy tt ON tt.term_id=t.term_id
  LEFT JOIN wp_term_relationships tr ON tr.term_taxonomy_id=tt.term_taxonomy_id
  WHERE tt.taxonomy LIKE 'pa_%' GROUP BY t.name HAVING adet = 0 LIMIT 20;"

That lists attribute values attached to nothing. Each is an option a customer can select to reach an empty page, and they accumulate as products are retired.

Show counts next to each option and hide the ones at zero. It costs a little more work per page and removes the interaction that makes a well stocked shop feel empty. Improving product pages covers where they land next.