How it works
Search, filters and sorting are three separate features that work together on one results screen.
Search: from query to results
- The user types a query. For example
mug. Many apps start searching while you type (“search as you type”); others wait for the Search key or button. - The app waits a moment (debounce). A good app doesn’t send a request on every keystroke. It waits until you pause typing for around 200–500 ms. This is called a debounceDebounceWaiting until the user stops typing for a moment before reacting, for example before searching.Open in glossary →.
- The app sends a request. It asks the server for matching products through the server’s APIAPIThe way different software parts talk to each other, like an app asking a server for data.Open in glossary →. The active filters and the sort order usually travel in the same request.
Dev note
Something likeGET /api/search?q=mug&cat=kitchen&sort=price_asc. - The server finds matches. It first cleans up the query (trims spaces, ignores upper/lower case, often ignores accents like é), then ranks the results by relevance: the best matches come first.
- The app shows the results. It shows a loading stateLoading stateWhat the UI shows while it waits for data or an action to finish, such as a spinner or skeleton.Open in glossary → while waiting, then the results, a results count and the matched words highlighted. If nothing matches, it shows an empty stateEmpty stateThe screen a user sees when there is no content yet, like an empty cart or no search results.Open in glossary → with a helpful message.
- More results load on demand. Long lists are split into pages: numbered pagination (“Page 2 of 8”) or infinite scrollInfinite scrollLoading more items automatically when the user reaches the bottom of a list.Open in glossary → (the next batch loads as you reach the bottom).
Extra helpers you’ll often meet:
- AutocompleteAutocompleteSuggestions shown under a field while typing, which the user can pick to finish the input.Open in glossary → / suggestions: a dropdown under the search box with suggested queries or products while you type (“mug” → “mug set”, “travel mug”).
- Recent searches: your last few queries, shown when you tap the empty search box. They should be removable and private to your account or device.
- Spelling tolerance: “headphnes” still finds headphones, or the app asks “Did you mean headphones?”
See for yourself why debouncing matters. Type quickly with the debounce on, then turn it off and try again:
Try it: type “wireless earbuds” quickly
Keystrokes
0
Requests sent
0
Network log
- No requests yet…
Filters: narrowing the list
Filters let the user narrow results by attributes: category, price range, size, rating, availability.
| Filter type | Looks like | Example |
|---|---|---|
| Chips | Small pill buttons you tap on and off | Kitchen, In stock, 4★ & up |
| Checkboxes | A list in a side panel, or on phones in a bottom sheet (a panel that slides up from the bottom) | Brand: ☐ Nike ☐ Adidas ☐ Puma |
| Range | A slider with two handles, or min/max fields | Price: $20 – $100 |
| Single choice | Radio buttonsRadio buttonA round option in a group where exactly one can be selected; choosing one unselects the others.Open in glossary → or a dropdown | Delivery: Today / This week |
| Toggle | A switch | Free shipping only |
Things every filter UI should have:
- A filter count badge, like Filters (3), so the user knows filters are active even when the panel is closed.
- Clear all to remove every filter at once, and a way to remove a single filter (often an × on the chip).
- An updated results count after every change.
Sorting: putting results in order
Sorting changes the order, never the set of results. The count must stay the same when you change the sort.
| Sort option | Correct order | Watch out for |
|---|---|---|
| Relevance (default) | Best match first | Exact matches should beat partial ones |
| Price: low to high | $5.49, $8.99, $12.50, $100 | Sorting prices as text gives $100 before $12.50 |
| Price: high to low | The reverse | Sale prices vs. original prices: which one is used? |
| Top rated | 4.9 before 4.1 | Products with 1 review of 5★ ranking above 2,000 reviews of 4.8★ |
| Newest | Most recently added first | Time zones and items with the same date |
Ties happen all the time: two products cost $19.99. A good sort is stable: items that tie keep a consistent order (for example, by relevance), so they don’t jump around every time you reload or load the next page. Unstable ties can even cause a product to appear on page 1 and page 2, while another product never appears at all.
URL state on the web
On a website, the current search, filters and sort should live in the address bar:
shop.example.com/search?q=mug&cat=kitchen&sort=price_ascEverything after the ? is a list of query parametersQuery parameterData in a URL after the ?, like ?q=mug&sort=price, often used to keep search and filter state.Open in glossary →, name=value pairs joined by &: here the query (q), the category (cat) and the sort order (sort). The names differ from site to site, but you can read them without any tools.
This gives users three important things:
- Shareable links: paste the URL to a friend and they see the same results.
- Back button works: open a product, press Back, and you return to the same filtered list, ideally at the same scroll position.
- Refresh keeps state: reloading the page doesn’t wipe your filters.
Mobile apps don’t have an address bar, but the same idea applies: going back from a product should keep your query, filters, sort and scroll position. Some apps also support deep linksDeep linkA link that opens a specific screen inside an app instead of just its home screen.Open in glossary → that open a pre-filtered search.
Example requirements
Notice how testable each line is. Criterion 7 alone gives you a check to run after every other test. Learn more in acceptance criteriaAcceptance criteriaConditions a user story must meet to be considered done and accepted.Open in glossary → and user storyUser storyA short description of a feature from the user's point of view.Open in glossary →.
Check this part
You select the "Kitchen" and "Home" category chips. What should usually happen to the number of results?
You change the sort from Relevance to Price: low to high. What should happen to the results count?
Why should search filters and sort be stored in the URL on a website?