Simple Search: How the Single Search Box Powers the Web

By · Updated

“Simple search” should mean a small, explicit contract: lexical matching over a bounded corpus, one query box, deterministic ranking, and no infrastructure the team cannot operate. It should not mean substring scans, inaccessible controls, or relevance nobody measures. Start with the database already serving the content and move to a dedicated engine only when evidence identifies the boundary.

Define the minimum useful contract

Index a stable document ID, title, searchable body, canonical URL, type, language, and updated timestamp. Decide how creates, updates, and deletes reach the index. The query contract should specify tokenization, phrase handling, field weights, filters, result limit, ordering ties, and empty-query behavior. These choices are more important than the number of features in the interface.

A useful baseline ranks exact identifier and title matches above body matches, filters inaccessible or unpublished documents before ranking, and returns a short snippet showing why the result matched.

Use a local full-text index before a remote service

SQLite FTS5 is sufficient for many desktop tools and small sites. Its official documentation covers virtual tables, phrase queries, prefix queries, highlighting, and BM25 ranking. A minimal schema can remain close to application data:

CREATE VIRTUAL TABLE search_docs
USING fts5(title, body, url UNINDEXED, tokenize = 'unicode61');

SELECT url, title, bm25(search_docs, 8.0, 1.0) AS score
FROM search_docs
WHERE search_docs MATCH ?
ORDER BY score
LIMIT 20;

PostgreSQL offers language dictionaries, weighted tsvector fields, ranking, and indexes in its full-text search subsystem. Keeping search transactional with the source database removes an entire synchronization failure mode.

Add only the behavior users demonstrate they need

Review real zero-result and reformulated queries. Add a synonym only when two terms are equivalent in this corpus; add typo tolerance when spelling errors are common; add filters when users need to narrow a large result set. Prefix matching is useful for suggestions but can make ordinary result ranking noisy and expensive. Semantic retrieval is not the default answer to poor titles or missing content.

If suggestions are added, follow the WAI-ARIA combobox keyboard and focus pattern. A plain labelled search field and submit button are often better than an incomplete autocomplete widget.

Know the migration triggers

Move beyond the database when measured requirements demand independent scaling, cross-source ingestion, advanced multilingual analysis, near-real-time faceting, vector retrieval, or availability isolated from the primary store. Before migrating, preserve a judged query set, an exportable corpus, and an application-owned result model. Test deletion lag, stale replicas, empty indexes, and rollback as carefully as relevance.

Search, Web, Cloud

Published · Updated