Short answer: choose chunk boundaries that preserve one travel decision and its evidence, then measure retrieval quality on a labeled itinerary set before you commit to an index. The right retrieval architecture for a travel itinerary planner is staged: deterministic ingestion, explicit metadata filters, bounded queries, and citation validation are separate steps.
I care about this boundary because operational failures are rarely dramatic at first. I've been paged by missed jobs and duplicate deliveries; a retrieval system has the same shape of failure. A planner can return a beautiful three-day route while silently combining a winter timetable with a summer fare. The text sounds right. The source trail is wrong.
What search architecture fits a travel itinerary planner with safe chunk boundaries?
Start with the answer contract, not the embedding model. A generated recommendation should point to the exact source passage that supports the train departure, opening hours, visa rule, or cancellation condition. That means every indexed chunk needs a stable document ID, revision, chunk ID, and locator such as page, section, or URL fragment. Keep the source URL and capture timestamp too; travel facts change.
The retrieval unit should match a decision. A whole guidebook is too broad for a question about a ferry cutoff. A sentence is often too narrow to carry the date, exception, and place name together. For itinerary documents, a useful default is a section-sized chunk bounded by a heading, an itinerary day, or a policy rule, with a small overlap only when a sentence continues across the boundary. Store the parent section and neighboring chunk IDs so a reviewer can widen context without asking the model to invent it.
Chunk boundaries are a correctness control.
Use metadata to narrow the search before similarity ranking: destination, language, travel date range, source type, and document revision are more reliable than semantic similarity for hard constraints. Do not put every filter in the prompt. A query for “late arrival in Kyoto” should already exclude a Paris guide and an expired 2024 timetable before the generator sees candidates.
Freshness is part of the retrieval contract. Set a policy per source: airline schedule data may need hourly checks, while a museum accessibility guide might be reviewed weekly. When a revision arrives, create deterministic IDs from document revision and chunk position, write the desired set, then remove IDs absent from that set. A successful write is not proof that deleted content is gone.
The incident pattern: plausible answers, untraceable evidence
The dangerous failure is not an empty result. It is a plausible result with the wrong lineage. In a postmortem, I would ask four questions: which revision was observed, which filters were applied, which chunks were selected, and which citation was shown to the traveler? If any answer requires reconstructing logs by hand, the design has already lost useful evidence.
Make the evidence path boring.
In a real itinerary flow, the failure often starts several hours before the bad answer. A supplier republishes a rail PDF with the same filename, the ingestion worker sees a successful upload, and the index now contains both revisions because the record key used only the URL. A query for “last train after the concert” retrieves the newer station map and the older timetable; both mention the same station, so a similarity score cannot expose the mismatch. The planner then cites a page that a reviewer can open, but that page no longer contains the departure it appears to support. The fix is not a clever prompt. Persist the revision fingerprint, make it part of the chunk identity, retain the capture timestamp, and have the query filter select one approved revision before ranking. During reconciliation, compare the desired IDs with the existing IDs and record every removal. That sequence gives an operator a finite set of facts to inspect after a missed job or duplicate delivery, instead of asking them to infer state from whichever document happened to rank first.
Keep ingestion, querying, and answer citation as independently observable stages. Record a request ID, collection or namespace, filter set, result limit, timeout, selected chunk IDs, and validation outcome. Persist the answer-to-chunk mapping before publishing the itinerary. If validation fails, return a review state or a narrower answer; do not fill the gap with a confident sentence.
A small labeled evaluation set catches boundary mistakes quickly. Include questions that cross a heading, contain two cities, ask for a date-specific exception, and require a negative answer such as “is this route closed on Mondays?” Label the supporting chunk and the acceptable citation locator. Measure recall of the supporting chunk, precision of the returned set, citation validity, and freshness separately. One blended score hides the failure that matters.
I once assumed that increasing overlap would solve missed context. It helped one cross-heading case, then increased near-duplicate candidates and made citations harder to inspect. Your mileage may vary: the useful overlap depends on document grammar, not a universal token count.
A small Go contract keeps retrieval honest
The application layer should expose a narrow retrieval operation. Provider-specific payloads, embedding settings, and retry details belong behind the adapter. This example validates the evidence shape before generation and makes timeout and empty-result behavior explicit.
package retrieval
import (
"context"
"errors"
"time"
)
var ErrNoEvidence = errors.New("no traceable evidence")
type Filter struct {
Destination string
Language string
TravelDate time.Time
Revision string
}
type Chunk struct {
ID string
DocumentID string
Revision string
Locator string
Text string
}
type Query struct {
Text string
Filter Filter
Limit int
RequestID string
}
type Index interface {
Search(context.Context, Query) ([]Chunk, error)
}
func Retrieve(ctx context.Context, index Index, q Query, timeout time.Duration) ([]Chunk, error) {
if q.Limit < 1 || q.Limit > 20 {
return nil, errors.New("result limit outside policy")
}
if q.RequestID == "" || q.Filter.Destination == "" {
return nil, errors.New("request ID and destination are required")
}
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
chunks, err := index.Search(ctx, q)
if err != nil {
return nil, err
}
for _, c := range chunks {
if c.ID == "" || c.DocumentID == "" || c.Revision == "" || c.Locator == "" || c.Text == "" {
return nil, errors.New("untraceable chunk returned")
}
}
if len(chunks) == 0 {
return nil, ErrNoEvidence
}
return chunks, nil
}
The limit is deliberately bounded, and the timeout is supplied by the caller because an interactive planner and a nightly re-index have different budgets. A 429 or network timeout should be retried by the adapter with a finite budget and a request ID; the business layer should see a typed failure, not a second itinerary request. Keep retry telemetry separate from citation telemetry so latency pressure cannot hide evidence loss.
Comparing designs without turning the choice into a leaderboard
Evaluate a managed vector service, a relational extension, and a self-hosted search stack with the same corpus and lifecycle. Run initial ingestion, a one-line timetable edit, a full document replacement, a deletion, and date-filtered queries. Hold chunking, embedding, replica count, and retention constant. Compare p95 latency, stale-record rate, citation validity, operator effort, and recovery behavior.
| Design | Useful fit | Trade-off to test |
|---|---|---|
| Managed vector index | Small team wants operations outsourced | Replacement churn and export behavior become external dependencies |
| Relational vector extension | Audit records and chunks should share transactions | Growth may require careful vacuuming, indexing, and capacity work |
| Self-hosted search cluster | Team needs control over ranking and data locality | Upgrades, replicas, and on-call response are yours |
No option wins by default. A managed index is not suitable when policy requires a storage location or deletion workflow it cannot demonstrate. A relational design is not suitable when the corpus and query volume exceed the team's tested capacity. Self-hosting is a poor fit for a solo SaaS if it turns itinerary correctness work into cluster maintenance. Stick with the simplest design that passes the evidence and lifecycle tests.
Rollout rules and the decision boundary
Ship in stages. First, replay the labeled set and inspect every citation. Next, shadow real queries without changing traveler-visible routes. Then expose citations to internal reviewers and record corrections by document type. Automate itinerary suggestions only after the relevant question classes meet the written quality and freshness floors.
The architecture decision is the evidence contract: deterministic chunk IDs, explicit filters, bounded retrieval, and durable lineage. The index choice follows from measured fit, recovery time, and ownership capacity. Price can be part of that worksheet, but it cannot compensate for a citation that points at the wrong revision.
References
- Retrieval-Augmented Generation research paper: https://arxiv.org/abs/2005.11401
- RFC 9110, HTTP Semantics (status and request behavior): https://www.rfc-editor.org/rfc/rfc9110
- W3C PROV-DM provenance data model: https://www.w3.org/TR/prov-dm/
- OWASP Logging Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html
Top comments (0)