Skip to content

[00] Subset Search, User guide

How searching works

How Subset Search matches and ranks results, the search syntax visitors can use, and every setting on the Search and Index tabs.

This page explains how a search is matched and ranked, so you can tell why a result comes first and which setting to change when it shouldn’t. The Tester at Subset → Search → Tester shows each of these steps for a search you type.

From words to results

A search runs in four steps:

  1. The words are read the same way your content was indexed: lowercased, accents folded, stopwords dropped and, on an English site, stemmed. “Booking” and “bookings” both become “book”.
  2. Posts with every word are found. If that finds nothing, posts with words that start with the search words are tried, then posts with any of the words.
  3. Each post is scored with BM25, the formula most search engines start from. A word counts more when it’s rare across your site, when it appears more often in the post, and when it’s in a part of the post with a higher weight. A long post doesn’t outrank a short one only because it’s long.
  4. WordPress’s own rules are applied to the best results: only published posts, private ones only for people allowed to read them, and any filters other plugins add. Then the page of results goes to your theme.

At most 1,000 results are scored per search, best first, and only those can be paged through. The Tester says when a search hits that cap.

What visitors can type

TypedWhat it does
opening hoursFinds posts with both words, anywhere in the post.
"opening hours"Finds posts with the phrase: both words together, in that order.
hours -sundayLeaves out posts that contain “sunday”.
catWith partial words on, also finds “catalogue” when nothing matches “cat” itself.

A search uses its first 16 words, and the Tester lists any it left out. When no post has a quoted phrase exactly, its words are matched anywhere instead, and a line above the results says so.

The Search tab

Changes on this tab apply to the next search, without a rebuild.

SettingDefaultWhat it does
MatchEvery wordPosts with every word searched for, or posts with any word, most matches first.
FallbackOnWhen no post has every word, show posts with any of them.
Partial wordsWhen nothing matchesAlso match words the search words start, for words of three letters or more: when nothing matches the words themselves, always, or never. A partial match counts 60% of a whole word.
PhrasesOnWords in quotes must appear together, in order. Off, quotes are ignored.
SynonymsNoneOne word per line, then its synonyms: car = automobile, vehicle.
WeightsSee belowHow much a word counts in each part of a post.
Post type weights1 for every typeEvery result of a type is multiplied by its weight, so 1.5 ranks products above posts that match as well.
ExcerptsOnShow the part of each post that matches, with the matched words highlighted.
Excerpt length30 words
TitlesOffHighlight the matched words in result titles.
Did you meanOnSuggest a corrected search when a search finds too little.
Suggest below1Results. 1 suggests only when a search finds nothing.
Admin searchOffRank searches on the Posts, Pages and other admin list screens too.

Weights

Part of a postDefault weight
Title5
Categories, tags and terms3
Excerpt2
Custom fields2
Author name2
Content1
Comments0.5

A word in a title counts five times as much as one in the content. A post whose title holds every word searched for scores half as much again. Set a weight to 0 to ignore that part of a post.

Synonyms

Synonyms are one-way. car = automobile, vehicle makes a search for “car” also find “automobile” and “vehicle”, but a search for “vehicle” doesn’t find “car”. To make two words find each other, add a line for each. Each word and synonym has to be a single word.

On the Searches tab, the No results view shows the words your visitors use that your posts don’t. Add synonym under one of them fills it in here.

The Index tab

These settings change what’s in the index, so after you save one the tab asks you to rebuild it.

SettingDefaultWhat it does
Post typesEvery public typeWhich post types are indexed and searched. A type that’s excluded from search is never indexed.
MediaOffIndex media titles, captions, descriptions and alt text.
Private postsOffIndex private and scheduled posts. They appear only to people allowed to read them.
TaxonomiesEvery public taxonomyThe names of a post’s terms in these taxonomies are indexed with it.
Term descriptionsOffIndex term descriptions too.
Custom fieldsNoneOne meta key per line. % matches any characters, so price_% indexes price_min and price_max.
AuthorOnIndex the author’s display name.
CommentsOffIndex approved comments.
ShortcodesOffIndex the output of the shortcodes you list. Other shortcodes are removed before indexing.
Shortest word2Shorter words are neither indexed nor searched. Chinese, Japanese and Korean characters are always kept.
AccentsOnMatch words with and without accents: “cafe” finds “café”.
Word positionsOffKeep where each word sits in the content, so phrases are checked from the index. Faster phrase searches on large sites, for a bigger index.
StopwordsThe list for your site’s languageCommon words left out of the index and out of searches.

A custom field pattern starting with % doesn’t match hidden fields, the ones whose keys start with _. List those by name, or with a pattern that starts with _, such as _price%.

Content is indexed as your site shows it: blocks are rendered, reusable blocks included, and text in image alt and title attributes is kept. A password-protected post is indexed by its title only.

Stopwords

Stopwords are words so common that they’d match almost every post, such as “the” and “and”. Leaving them out keeps the index smaller and the results sharper. A search made only of stopwords still finds posts.

The list starts as the one bundled for your site’s language. Edit it on the Index tab, one word per line, and click Reset to the list for the site language to go back. On an English site, words are also stemmed, so “connected”, “connecting” and “connection” all match each other. Other languages are indexed without stemming.

The index’s size

The Index tab shows the index’s size next to your posts table’s. On our generated test site of 10,000 long posts, the index is about two thirds the size of the posts table. Yours depends on your content and settings. To make it smaller, index fewer post types, leave comments out, raise the shortest word or keep word positions off.