# Storefront search

> How search works on every store: instant suggestions, typo tolerance, built-in shorthand and your own synonyms, ranking, filters and the /search page, pinned results and redirects, and search insights.

Source: https://shopfa.st/docs/store/search

Every template has the same search: a box in the header with instant suggestions, a full `/search` page with
filters, and the tools in **Storefront → Search** to tune it. There is nothing to install or turn on.

## What buyers get

- **Instant suggestions** under the header's search box: products, collections and pages as they type, with the
  most popular searches when the box is empty and their recent searches kept in the browser.
- **Keyboard first**: `/` focuses the search box, and <kbd>⌘</kbd> <kbd>K</kbd> (<kbd>Ctrl</kbd> <kbd>K</kbd>)
  opens it as a palette on templates without a visible box. The arrow keys move through suggestions and
  <kbd>Enter</kbd> opens one.
- **On phones** the search opens as a full-screen sheet, and the filters as a bottom sheet.
- **The `/search` page**: results 24 to a page with filters, sorting, a result count and a shareable URL.

## Typos and shorthand

Search reads what buyers mean, not only what they typed:

- **Typos.** A word that is not in your store gets the nearest words that are (one edit for words up to four letters,
  two up to eight, three beyond; a swap of two letters counts as one). "ironviel" finds Ironveil. The page says
  "Showing results for" with a link back to what was typed. Words of one or two letters, numbers and shorthand are
  never corrected.
- **Word starts.** Words also match the start of longer words, so "drift" already finds Driftline while the buyer types.
- **Accents and case** are ignored ("Pokémon" and "pokemon" are the same search).
- **Shorthand**, built in: "key" finds license and serial, "lifetime" finds permanent, "monthly" finds 30 Days,
  "cfg" and "config" find each other, "mc" finds Minecraft, and dozens more.
  **Storefront → Search → Synonyms** lists them all.
- **Your synonyms.** Add your own groups. Two-way groups are true equivalents (each word finds the others); one-way
  rules expand a short form only ("ivp" finds "Ironveil Pro", but "Ironveil" does not also look for "ivp").
- **Fewer words.** When nothing matches every word, the page shows products that match some of them and says so.

## What is searched, and how it ranks

Search covers listed products that are on sale, published collections and published pages. Unlisted and draft
products never show.

A match in the **title** counts most, then **tags, game, platforms, product type and collections**, then
**options and durations, the short description and key features**, then the **description and requirements**.
Among good matches, products that sold more in the last 30 days, rate higher and are newer come first. Products that
cannot be bought right now sink: sold out, [paused](https://shopfa.st/docs/store/product-status#auto-pause), not working or down, and
slightly testing or updating.

The index rebuilds itself after you change products, collections or pages (a buyer's search carries your catalog's
version, and a newer one refreshes the index), and at least every 15 minutes. **Rebuild now** in Storefront →
Search does it at once.

## Filters and the search page URL

The search page's state lives in its URL, so a filtered search can be shared, bookmarked or linked from your own
pages and Discord. Filters combine with OR inside one filter and AND across filters, and each filter's counts
ignore its own selection, so buyers always see how many products picking another value would show.

| Parameter | Example | Meaning |
| --- | --- | --- |
| `q` | `q=ironveil pro` | The search words (up to 100 characters) |
| `game` | `game=hearthmoor,skyreach` | One or more games |
| `platform` | `platform=windows,steam` | `windows`, `mac`, `linux`, `steam`, `epic`, `battlenet`, `riot`, `ea`, `ubisoft`, `xbox`, `playstation`, `switch`, `android`, `ios`, `web`, `other` |
| `type` | `type=license_key` | Product type |
| `duration` | `duration=7d,lifetime` | `1d`, `3d`, `7d`, `14d`, `30d`, `90d`, `180d`, `365d`, `lifetime` |
| `status` | `status=undetected,updated` | The [product status](https://shopfa.st/docs/store/product-status): `undetected` (Working), `updated`, `testing`, `updating`, `detected` (Not working), `down` |
| `stock` | `stock=1` | In stock only |
| `rating` | `rating=4` | At least this many stars |
| `min`, `max` | `min=5&max=30` | Price range in your store's currency |
| `sort` | `sort=price_asc` | `relevance` (the default with words), `best_selling` (the default without), `price_asc`, `price_desc`, `newest`, `rating` |
| `page` | `page=2` | The result page |

Lists take commas or repeated parameters: `/search?q=key&duration=7d,30d&stock=1&sort=price_asc`.

## Pins and redirects

**Storefront → Search → Pins & redirects** shapes single searches. Searches are matched after folding case,
accents and punctuation, so "Status!" and "status" are the same search.

- **Pin** up to 12 products to a search: they come first, in your order, above the normal results.
- **Redirect** a search to a page on your store (`/status`, `/collections/lifetime`) or an `https://` address. A buyer
  who searches for it lands there directly.

**Try a search** in the same place shows what buyers get for any words, with synonyms, typo corrections, pins and
redirects applied. Previews are never counted in your insights.

## Search insights

**Storefront → Search → Insights** shows the top searches, searches with no results (the products or synonyms to add
next), click-through on results and searches that led to a purchase. Searches are counted once a buyer stops typing,
and search history is kept for 400 days.

## For theme developers

Every template uses the shared `search-bar` snippet in its header and the `search-results` snippet around its own
product grid on the search page. A custom search template keeps four hooks so the runtime can wire the box, the
palette, the sheet and the filters: `[data-sf-search-page]`, `[data-sf-search-form]`, `input[data-sf-search]` and
`[data-sf-search-results]`.
