Choose chunk boundaries by the evidence a reader must verify, then measure whether retrieval returns that evidence intact. For a property-listing aggregator, that usually means keeping a claim such as rent, availability, address, or pet policy attached to its source identity and effective date. Smaller chunks can isolate a fact but shed its qualifiers. Larger chunks retain context but can bury the matching passage.
TL;DR: chunking changes which text units are eligible to be retrieved. It cannot repair stale source data or invent grounding. Start with semantic records, add a small overlap only where a record crosses a boundary, and evaluate retrieval with citation-aware queries before tuning size. This is the field guide I would use:
| Strategy | Pick this when | Main retrieval risk | Citation check |
|---|---|---|---|
| One listing record per chunk | Sources already expose complete, structured listings | Long descriptions may dominate the record | Can every returned claim point to one listing and capture time? |
| Field-group chunks | Users search for narrow facts such as fees or pet rules | Detached qualifiers can change meaning | Are value, unit, condition, and source kept together? |
| Fixed token windows | Input is mostly unstructured prose | Windows split records or combine properties | Does each window contain exactly the evidence its citation names? |
| Parent-child retrieval | Small passages match well, but the answer needs broader listing context | Parent expansion adds unrelated or stale text | Is the cited child preserved inside the returned parent? |
The decision is operational, not cosmetic. RAG retrieves external passages and conditions generation on them; changing passage boundaries changes the candidates available to that retrieval step. A polished answer can still be poorly grounded when its winning chunk lost the sentence that limits a concession to new leases.
Scores can lie.
What does chunking change in retrieval?
Imagine two feeds describing the same apartment. One says, “Rent: $2,400 monthly. Available November 1.” Another says, “One month concession for 13-month leases signed by October 15.” A blind window might end after “one month concession” and place the lease condition in the next chunk. The first fragment has excellent lexical appeal for a query about move-in offers. It is also incomplete evidence.
This is the trap.
Chunking controls three things at once: the unit scored by retrieval, the context returned with a match, and the smallest object that can carry citation metadata. Those effects pull in different directions. A tiny chunk concentrates matching terms. Yet “pets allowed” without “cats only,” or “parking included” without “for one vehicle,” is a retrieval failure even if the similarity score is high. A very large chunk keeps those qualifications, but it may contain two unit types, several dates, and boilerplate that competes with the useful text. Suppose retrieval returns only the top 5 candidates: three overlapping fragments from one verbose description can consume most of that budget while a distinct availability record falls to position 6. Increasing overlap helped boundary recall but hurt evidence diversity. That is a real trade-off created by the chunking policy, even though no source record or ranking formula changed.
Here is the diagram in words: source document to normalized listing snapshot to evidence chunks to retrieval candidates to cited answer. Put a trace identifier at every arrow. If a claim cannot travel backward from answer to chunk, snapshot, and source, the system has no useful grounding contract.
That trace matters because retrieval quality has layers. Did the system fetch the correct property? Did it fetch the right version of that property? Did the returned span preserve the qualifier? Did the answer cite the span that actually supports the claim? A single “relevant result” metric hides all four.
Pick this when the source already has records
Use one semantic record per chunk when an upstream listing arrives as a coherent object. Keep stable identifiers, source identity, observation time, and the fields needed to interpret a claim. The searchable text can be readable, while metadata remains structured for filtering and attribution.
I would choose this as the baseline for aggregation because a boundary follows the domain object instead of an arbitrary character count. It also gives operators a crisp invariant: a chunk describes one listing snapshot from one source. That is an editorial choice about the evidence contract, not a claim that record chunks always rank best.
The trade-off appears in verbose descriptions. A record with amenities, neighborhood copy, disclosure text, and multiple floor plans may be too broad for precise matching. Split only the long field, then attach each child to the same snapshot. Do not duplicate changing facts into every child unless the ingestion process updates them atomically; duplicated rent or availability can make old children look current.
Pick this when questions target one field group
Field-group chunks work for queries with a stable intent: recurring charges, lease terms, accessibility, utilities, parking, or pet restrictions. Group fields by the claim they jointly qualify, not by their position in the source payload. “Pet fee: $300” belongs with whether the fee is refundable and whether it is per pet. That bundle is the evidence.
This design improves narrow retrieval, but it raises the burden on metadata and answer assembly. A fee chunk needs the property ID and snapshot ID even when its text does not repeat the address. It may also need a validity interval if the source supplies one. Without those links, the retriever can return a correct fee for the wrong version of a listing.
Use fixed windows only as a fallback for prose that has no dependable record structure. Even then, split on paragraphs or sentences before applying a size ceiling. Overlap is insurance for a boundary, not a relevance strategy. More overlap creates near-duplicate candidates; those candidates can crowd out distinct evidence in a limited result set.
Instrument one Node.js implementation
The implementation below makes the evidence contract explicit. It does not prescribe an embedding model, database, or ranking algorithm. Every chunk carries the identifiers required to reconstruct its origin, while the text keeps a qualified claim readable.
type ListingSnapshot = {
listingId: string;
sourceId: string;
snapshotId: string;
observedAt: string;
address: string;
rent: { amount: number; currency: string; period: "month" };
availability: string;
petPolicy?: { allowed: string; fee?: string; conditions?: string };
};
type EvidenceChunk = {
chunkId: string;
listingId: string;
sourceId: string;
snapshotId: string;
observedAt: string;
claimType: "summary" | "pet-policy";
text: string;
};
function buildChunks(record: ListingSnapshot): EvidenceChunk[] {
const base = {
listingId: record.listingId,
sourceId: record.sourceId,
snapshotId: record.snapshotId,
observedAt: record.observedAt,
};
const chunks: EvidenceChunk[] = [{
...base,
chunkId: `${record.snapshotId}:summary`,
claimType: "summary",
text: `${record.address}. Rent: ${record.rent.amount} ${record.rent.currency} per ${record.rent.period}. Available: ${record.availability}.`,
}];
if (record.petPolicy) {
const policy = record.petPolicy;
chunks.push({
...base,
chunkId: `${record.snapshotId}:pet-policy`,
claimType: "pet-policy",
text: [
`Pet policy for ${record.address}: ${policy.allowed}.`,
policy.fee ? `Fee: ${policy.fee}.` : "",
policy.conditions ? `Conditions: ${policy.conditions}.` : "",
].filter(Boolean).join(" "),
});
}
return chunks;
}
Notice what is absent: a universal chunk length. The summary is short because the claim is short. The pet-policy chunk grows only when qualifiers exist. In production, validate timestamps and identifiers at ingestion, and reject malformed records before indexing. Silent partial chunks are worse than visible ingestion errors because they can still rank.
Log the retrieval decision as structured data, but do not log private applicant data or unrestricted source payloads. A compact event can capture the experiment and citation trail:
type RetrievalEvent = {
traceId: string;
queryClass: "rent" | "availability" | "pet-policy" | "other";
chunkingVersion: string;
candidateChunkIds: string[];
citedChunkIds: string[];
citedSnapshotIds: string[];
latencyMs: number;
};
function recordRetrieval(event: RetrievalEvent): void {
process.stdout.write(`${JSON.stringify({ event: "retrieval", ...event })}\n`);
}
Version the chunker. Otherwise, a quality shift after deployment cannot be separated from a corpus refresh or ranking change. A label such as record-fields-v1 belongs in offline evaluation results and live traces. For metrics, start with rates that correspond to visible failure: correct listing in the candidate set, supporting chunk in the candidate set, cited claim supported by the cited chunk, and citation resolving to the indexed snapshot. Break them down by query class and source. An aggregate can look stable while pet-policy retrieval collapses for one feed. Alerts should follow user harm, so a sudden rise in unresolved citations or missing snapshot IDs deserves attention. Latency alone cannot tell you whether an answer is supportable. Keep latency and candidate counts as diagnostic signals, then pair them with grounding checks.
Evaluate boundaries before changing them
Build an evaluation set from realistic questions and explicit evidence labels. For each question, record the listing snapshot and the minimal spans needed to answer it. Include adversarial pairs: same address with different unit numbers, current and older snapshots, a base rent beside a conditional concession, and similar pet policies with different exceptions.
Then compare chunking strategies while holding the corpus, query set, and retrieval method constant. Track retrieval at a fixed candidate budget. The useful question is not “Which chunk size wins?” It is “Which boundary policy returns complete, citable evidence for the query classes we serve?”
A before-and-after review should inspect misses, not just averages. If field-group chunks recover more pet-policy evidence but lose property identity, the remedy may be richer attached context rather than larger chunks everywhere. If overlap fills most candidate slots with adjacent copies, reduce overlap or collapse siblings after retrieval. Make one change per experiment. Keep it legible.
There is also a deployment trap: re-chunking changes identifiers and invalidates comparisons unless old and new indexes are distinguishable. Run a shadow evaluation or separate index, stamp both with their chunking version, and compare on the same labeled queries. Rollback then means selecting the previous version, not guessing which records were rewritten.
Limits and decision rule
Chunking cannot establish that a listing source is accurate, current, or authorized. It cannot reconcile two feeds by itself. Deduplication, source precedence, freshness policy, and conflict presentation sit around retrieval and need their own tests.
Use record chunks for coherent snapshots, field groups for qualified narrow claims, parent-child retrieval when matching and reading need different scopes, and fixed windows for unstructured leftovers. The winning boundary is the smallest unit that preserves the complete claim and a resolvable citation under a fixed retrieval budget. Measure that by query class, watch it by chunking version, and treat every unsupported citation as a retrieval-quality signal rather than a formatting defect.
Top comments (0)