Paj Digital Labs
All articles
Web Design & Engineering

Website Search That Finds Answers: Ranking, Typos and Empty Results

Search quality depends on the documents and ranking rules, not the size of the input box. Index useful fields, handle imperfect queries and give readers a way forward when nothing matches.

Paj Digital Labs 4 min read
Web design workspace with desktop and laptop displays
Editorial illustration · Web Design & Engineering

A visitor types an exact error message into a technical blog and gets nothing because the punctuation differs from the article title. The search feature exists, but it has failed its most obvious job.

Site search needs a retrieval contract. What should be searchable, which fields matter most, and what does the interface do when the query is vague or imperfect? Answer those before choosing an engine.

Define the searchable document

For an article, index the title, excerpt, meaningful headings, category and body text. Remove navigation, advertisement labels and repeated author boilerplate. Otherwise every page can match the same irrelevant words.

Store a stable document ID and canonical URL. A search index is a derivative, not the editorial source of truth. Published status must control inclusion, and a deleted or unpublished article must leave the index through a reliable update process.

If documents have permissions, filter at the retrieval boundary using the caller's scope. Hiding an unauthorised result in the browser after returning its title or snippet is already a leak.

Start with a proven engine

Small static catalogues can use a maintained browser-safe search library. Larger catalogues or frequent updates may justify a server-side engine. Compare language support, typo handling, ranking controls, update behaviour and operational cost.

Avoid inventing a full-text engine with a collection of includes checks unless the requirement really is a tiny exact filter. Established libraries already handle tokenisation and ranking problems you will otherwise rediscover badly.

Measure the index size delivered to the browser. Sending every article's complete body to every visitor can undermine performance even when the search box is never used. Load an appropriate index on demand or choose a service-backed architecture when justified.

Make ranking explainable

A title match usually deserves more weight than a casual body mention. Headings and excerpts can provide strong evidence. Exact phrase matches may help for commands and error strings, but aggressive normalisation can destroy meaningful technical tokens.

  • Exact error — Preserve useful punctuation and codes
  • Misspelling — Offer tolerant matches without absurd expansion
  • Broad topic — Prefer useful introductory or hub pages
  • Specific command — Rank direct explanations above incidental mentions

Test terms such as C++, HTTP 502 and pm.max_children rather than evaluating only ordinary English phrases. Tokenisation suitable for recipes may be poor for engineering documentation.

Keep category filters separate from the query where possible. A visible filter lets someone narrow intent without learning an undocumented search syntax.

Present results with evidence

Show the title, concise excerpt and relevant category. Highlight matched text safely through the renderer's escaping mechanism, not by concatenating untrusted query text into HTML.

A snippet should explain why the page may help. Avoid a paragraph of repeated navigation text or a raw code fragment without context. If your engine generates excerpts, test escaping and character boundaries carefully.

Do not promise that the first result is the answer. Let users inspect several candidates, and make keyboard navigation and focus states clear. Search results are navigation, so use actual links with stable destinations.

Avoid racing responses

When search is remote, debounce appropriately and cancel or disregard stale requests. A slower response for an earlier query must not replace the results for the text currently in the input.

Keep the query and chosen filters in the URL when that makes results shareable and browser navigation useful. Do not include sensitive searches in URLs if your domain involves private information; the architecture and privacy policy should decide that boundary.

Display loading, failure and empty states distinctly. "No results" is not an honest message when the request actually failed. Preserve what the visitor typed so they can retry.

Make no-results useful

Offer a clear way to remove filters, correct spelling or browse a relevant topic. Do not dump the entire article catalogue as if it matched. For technical queries, exact wording may matter, so let the visitor retain it while trying a broader search.

Review aggregated no-result queries when collection is permitted and necessary. Remove sensitive data and define retention. Search logs can contain names, credentials or pasted private error output; they are not automatically harmless analytics.

Use those patterns to improve indexing or identify genuine content gaps. One query with no match is not automatically a request to generate a page.

Evaluate with a small judgement set

Write representative queries and the pages a knowledgeable reviewer expects near the top. Include misspellings, alternate names and queries that should have no result. Compare rankings before changing boosts.

Test keyboard operation, mobile layout and long titles. Verify newly published pages appear and unpublished ones disappear. A relevance tweak that improves five demonstrations but breaks permissions or indexing lifecycle is not an improvement.

Good search saves the reader from knowing your site structure. Its quality comes from useful documents, deliberate retrieval rules and honest states when the system is uncertain. The input box is simply where that work begins.

Paj Digital Labs

The engineering journal of Paj Digital Solutions — hosting, server infrastructure and web engineering, written by the people who run the servers.

Related reading