[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:
- 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”.
- 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.
- 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.
- 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
| Typed | What it does |
|---|---|
opening hours | Finds posts with both words, anywhere in the post. |
"opening hours" | Finds posts with the phrase: both words together, in that order. |
hours -sunday | Leaves out posts that contain “sunday”. |
cat | With 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.
| Setting | Default | What it does |
|---|---|---|
| Match | Every word | Posts with every word searched for, or posts with any word, most matches first. |
| Fallback | On | When no post has every word, show posts with any of them. |
| Partial words | When nothing matches | Also 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. |
| Phrases | On | Words in quotes must appear together, in order. Off, quotes are ignored. |
| Synonyms | None | One word per line, then its synonyms: car = automobile, vehicle. |
| Weights | See below | How much a word counts in each part of a post. |
| Post type weights | 1 for every type | Every result of a type is multiplied by its weight, so 1.5 ranks products above posts that match as well. |
| Excerpts | On | Show the part of each post that matches, with the matched words highlighted. |
| Excerpt length | 30 words | |
| Titles | Off | Highlight the matched words in result titles. |
| Did you mean | On | Suggest a corrected search when a search finds too little. |
| Suggest below | 1 | Results. 1 suggests only when a search finds nothing. |
| Admin search | Off | Rank searches on the Posts, Pages and other admin list screens too. |
Weights
| Part of a post | Default weight |
|---|---|
| Title | 5 |
| Categories, tags and terms | 3 |
| Excerpt | 2 |
| Custom fields | 2 |
| Author name | 2 |
| Content | 1 |
| Comments | 0.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.
| Setting | Default | What it does |
|---|---|---|
| Post types | Every public type | Which post types are indexed and searched. A type that’s excluded from search is never indexed. |
| Media | Off | Index media titles, captions, descriptions and alt text. |
| Private posts | Off | Index private and scheduled posts. They appear only to people allowed to read them. |
| Taxonomies | Every public taxonomy | The names of a post’s terms in these taxonomies are indexed with it. |
| Term descriptions | Off | Index term descriptions too. |
| Custom fields | None | One meta key per line. % matches any characters, so price_% indexes price_min and price_max. |
| Author | On | Index the author’s display name. |
| Comments | Off | Index approved comments. |
| Shortcodes | Off | Index the output of the shortcodes you list. Other shortcodes are removed before indexing. |
| Shortest word | 2 | Shorter words are neither indexed nor searched. Chinese, Japanese and Korean characters are always kept. |
| Accents | On | Match words with and without accents: “cafe” finds “café”. |
| Word positions | Off | Keep where each word sits in the content, so phrases are checked from the index. Faster phrase searches on large sites, for a bigger index. |
| Stopwords | The list for your site’s language | Common 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.