Carta Operum

Journal ◆ Server

Search by wine, grape, region or winery

One search box, four kinds of answer, and the ranking that decides which comes first.

Typing 'Rioja' into a wine shop could mean a region, a wine called Rioja or a winery with that word in its name, and typing 'Syrah' means a grape. The search box on Cellar does not ask which. It looks in four places, wines, grapes, regions and wineries, and shows the answers grouped, with the likeliest on top.

On the server each kind of answer is its own query over its own table, run together and merged into one response. Each has an index suited to how people search for it: prefix matching for names, exact matching for regions. A short list per group keeps the response small enough to feel instant on a phone.

Ranking is deliberately dull. An exact name beats a prefix, a prefix beats a word in the middle, and ties go to the product with more reviews. Caching on the server keeps the popular queries warm, so the first search of the evening is not the slowest one. I would resist anything cleverer until the logs show shoppers failing to find a bottle.