Short answer: use vector search for the menu corpus you are allowed to crawl and web search for discovery and freshness checks; do not let either system silently expand the crawl boundary. The useful unit is a dated, source-labeled menu chunk, not a URL and not an embedding by itself.
I learned this while reviewing a restaurant assistant that answered “does the lunch set include soup?” with a confident yes. The vector index contained last season’s PDF. The web result pointed at a current landing page, but its snippet described dinner. Nothing had crashed. The failure was a boundary decision: retrieval mixed documents with different freshness and authority, then the generator treated them as one answer. We traced the request through the logs and found three timestamps: the PDF had been fetched 41 days earlier, the landing page had changed twice since then, and the answer path had no field for either date. A reranker improved the ordering but could not repair missing provenance. The postmortem action was therefore a schema change and a crawl rule, followed by a regression fixture for the exact lunch question. That is slower than tweaking a prompt, and it is much easier to verify six weeks later.
That boundary matters.
That is the incident pattern to design against. A menu assistant has two jobs that look similar in a trace: find relevant text and decide whether that text is still valid. Chunking helps the first job. Crawl policy and freshness metadata control the second. Keep those stages visible in metrics so an on-call engineer can tell “no matching dish” from “matching dish, but stale source” without replaying the whole generation request.
What should a restaurant menu assistant retrieve first?
Start with a small, explicit source registry. A restaurant’s own menu page, an owner-managed PDF, and a delivery marketplace page are not equivalent evidence. Store the URL, fetch time, content hash, locale, meal period, and an authority label with every chunk. A query for “gluten-free ramen” can then filter to the right location and reject a stale lunch period before semantic ranking runs.
Vector search is a good fit after this normalization. Split by meaning: one chunk for a dish and its ingredients, another for allergy notes, and a separate chunk for hours or ordering rules. Do not split every two sentences just to reach a token target. A chunk that crosses “may contain” into a different dish creates a dangerous match even when its similarity score is high.
Web search has a different role. It can discover a newly published menu, an alternate location, or a page that your allowlist has not seen. Treat the result as a candidate URL. Fetch it through the same parser, record its timestamp, and place it in a review or re-index queue. A search snippet is evidence of where to look, not menu content to quote.
How do vector search and web search handle crawl boundaries and freshness?
Make the boundary a policy object, not an implicit side effect of a crawler. The policy should answer four questions: which hostnames are allowed, which paths are in scope, how often each source is refreshed, and what happens when a source disappears. robots.txt, terms of use, authentication requirements, and rate limits are operational inputs; they are not optional cleanup work.
A practical decision table looks like this:
| Need | Primary mechanism | Freshness guard | Failure response |
|---|---|---|---|
| Answer from an approved menu corpus | Vector search | Filter by location and max age | Say the menu could have changed and link the source |
| Find a new menu URL | Web search | Fetch and timestamp before indexing | Queue for validation; do not answer from the snippet |
| Confirm a daily special | Targeted page fetch | Short TTL and content hash | Ask the user for the restaurant and date |
| Handle allergy or ingredient risk | Structured fields plus retrieval | Require an explicit source date | Defer to the restaurant when evidence conflicts |
The catch is latency and coverage. A short TTL causes more fetches and parser work; a long TTL makes a fast embedding lookup confidently stale. Web search can improve discovery but cannot grant permission to crawl a page. Vector search can be fast and precise over your corpus but cannot know about a page you never collected.
Your mileage may vary by region and by how often restaurants edit their pages. I would rather expose “last checked yesterday” than invent a universal freshness number.
A small, testable retrieval gate in Go
The gate below keeps discovery separate from answerable evidence. It is intentionally boring: the caller must provide a validated candidate, and only chunks that pass age and authority checks reach generation.
package retrieval
import (
"errors"
"net/url"
"strings"
"time"
)
type Chunk struct {
URL string
Text string
Location string
FetchedAt time.Time
Authority string
}
type Policy struct {
AllowedHosts map[string]bool
MaxAge time.Duration
Location string
}
func Answerable(c Chunk, p Policy, now time.Time) error {
u, err := url.Parse(c.URL)
if err != nil || !p.AllowedHosts[strings.ToLower(u.Hostname())] {
return errors.New("source is outside the crawl boundary")
}
if c.Location != p.Location || c.Text == "" {
return errors.New("chunk is not scoped to this restaurant")
}
if now.Sub(c.FetchedAt) > p.MaxAge {
return errors.New("chunk is stale")
}
return nil
}
The production version should make the error observable with a reason counter and trace field. It should also make indexing idempotent: use a content hash as the document key, upsert the current version, and keep the previous version for audit. If a fetch retries after a timeout, the retry must not create duplicate chunks or reset FetchedAt without new content.
Test the boundary before testing the language model. Include fixtures for a disallowed host, an old PDF, two locations with the same dish name, and a page whose ingredient disclaimer moved to a separate section. Then assert that the assistant either cites an eligible chunk or asks for clarification. A fluent answer is not a passing test.
When is this split the wrong choice?
This design is not suitable when you need unrestricted, real-time coverage of user-generated listings, or when you cannot obtain permission to fetch the source pages. In those cases, stick with a search provider’s hosted result presentation or a smaller, explicitly licensed dataset, and be clear that the assistant is not a complete menu authority.
It is also a poor fit for a tiny, stable menu with no discovery requirement. A signed JSON feed or a manually maintained table may be easier to audit than two retrieval paths. The engineering rule is simple: add web discovery only when it resolves a known coverage gap, and add vectors only when lexical or structured filtering no longer gives reliable matches.
The original bug class was not “the model hallucinated.” It was an untracked document lifecycle. Once crawl permission, chunk scope, source date, and conflict handling are first-class fields, the choice between vector search and web search becomes an operational decision that can be tested, monitored, and rolled back.
Top comments (0)