Short answer: for a retrieval architecture serving a travel itinerary planner or a game-listing index, make each chunk a stable fact, keep volatile fields separate, and carry one listing ID through every record. That boundary keeps search useful without turning the index into a second database.
A listing is already a useful unit: title, platform, region, price, release window, and a short description. Split on that boundary before reaching for a character limit. The retriever can then return a complete candidate instead of a paragraph that lost its platform or region.
I treat the source payload as an envelope and derive searchable chunks from it. The envelope keeps provenance, while the chunk carries only fields that should participate in semantic matching. This distinction matters when ten feeds describe the same game with different punctuation.
Keep it boring.
Changing facts need their own path.
Prices, stock flags, and event dates change faster than embeddings should. Put them in filterable metadata or a side index, then apply those filters after candidate retrieval. A stale price inside a vector is a correctness problem, not a tuning problem.
For each source, normalize timestamps to ISO 8601 and retain the source URL. Do not silently merge two offers because their names look similar; use a deterministic listing key and make the merge decision observable.
1. How should retrieval architecture choose chunk boundaries for a travel itinerary planner?
The same rule transfers to a travel itinerary planner: one activity or reservation should remain intact when its date, location, and constraint belong together. A day-level summary can be a second chunk, but it should point back to the activity IDs. For game listings, the analogous parent is a title-day or catalog batch summary; it helps broad queries, while item chunks answer precise ones.
This two-level shape avoids a common failure mode. If every sentence becomes a chunk, retrieval returns fragments that cannot be acted on. If an entire catalog becomes one chunk, similarity hides the item the user actually needs. The boundary should follow the smallest unit a downstream action can cite.
2. Build the smallest working Node.js pipeline
The implementation below is deliberately boring. It creates deterministic chunks, records the source, and leaves embedding and storage behind narrow interfaces. That makes it possible to swap a hosted vector index for Postgres with pgvector, OpenSearch, or a local ANN library without rewriting ingestion.
type Listing = {
id: string;
title: string;
platform: string;
region: string;
description: string;
price?: number;
updatedAt: string;
sourceUrl: string;
};
type Chunk = {
id: string;
text: string;
metadata: Record<string, string>;
};
export function toChunk(listing: Listing): Chunk {
return {
id: "`${listing.id}:core`",
text: [listing.title, listing.platform, listing.region, listing.description].join("\
"),
metadata: {
listingId: listing.id,
platform: listing.platform,
region: listing.region,
updatedAt: listing.updatedAt,
sourceUrl: listing.sourceUrl
}
};
}
Notice what is absent: price. A query for “under 30” should use a numeric filter, not hope that an embedding remembers yesterday's number. The exact filter API depends on the index, so keep it in the repository layer.
| Approach | Ingestion shape | Best fit | Main limit |
|---|---|---|---|
| Item chunks | One stable record per listing | Precise catalog queries | Needs metadata filters |
| Day or batch summaries | Parent plus child IDs | Broad itinerary or catalog questions | Can hide item-level detail |
| Full documents | One large searchable unit | Small, slow-changing corpora | Weak pinpoint citations |
I log query ID, chunk IDs, source IDs, filter values, and final citations. Then inspect misses by class: wrong entity, stale metadata, duplicate feed, or insufficient context. Recall@k alone will not tell you which boundary failed. A small hand-labeled set of real marketplace questions is more useful than a synthetic score with no failure explanation.
Add deletion and update tests. Re-ingesting the same listing should produce the same chunk ID; updating a description should replace the old vector rather than append a twin. These invariants keep index cost predictable as feeds grow.
3. What changes when the catalog gets large?
At scale, batch embeddings, partition by region or platform, and schedule refreshes according to field volatility. Keep a queue for changed listings and a dead-letter path for malformed source records. Backpressure belongs at ingestion, before expensive embedding calls.
The catch is that this design is not suitable when users need full-document legal or editorial context in one retrieval hit. In that case, keep a parent document and fetch neighboring chunks after the initial match. Stick with a simpler full-document index when the corpus is small and updates are rare; the extra metadata and reconciliation logic will not pay for itself.
A good boundary has a name, an ID, a freshness policy, and a citation path. It also survives a provider change. Standards-based HTTP, ISO timestamps, and an internal chunk contract reduce glue code; the specific vector engine is a replaceable implementation detail.
I'm not sure any universal token threshold exists. Your mileage will vary with language, catalog shape, and query mix. Start with the action a result must support, test the failure classes, and only then adjust overlap or window size.
Top comments (0)