{"slug": "e-commerce-product-search-retrieval-go-s-5-freshness-checks-for-evaluation-sets", "title": "E-commerce Product Search Retrieval: Go's 5 Freshness Checks for Evaluation Sets", "summary": "A developer describes building a versioned, time-aware evaluation set for e-commerce product search retrieval, treating each test example as an event tied to a catalog snapshot, tenant, timestamp and graded judgments rather than a static row of text. The approach splits evaluation into four slices — exact identifiers, natural-language needs, policy-sensitive constraints and freshness probes — each with its own recall and ranking thresholds, and pairs a vector index with a lexical index plus a final filter that checks market and availability against the revision recorded in each candidate. The author argues that static evaluation sets can report flattering scores while shoppers see discontinued colors and stale prices, and provides a Go function that hashes product_id, revision, chunk_index and text into an idempotency key for chunk revisions.", "body_md": "Catalog changes are the constraint that decides whether an evaluation set is useful. Short answer: build a versioned, time-aware set of product queries and judge retrieval against the catalog state that existed when each query was issued; then use the same set to compare chunking, indexing, and refresh policies. A static set can report a flattering score while shoppers see discontinued colors and yesterday's prices.\n\nIn an e-commerce product search system, a result has two obligations: lexical or semantic relevance, and factual validity at serving time. The second obligation is easy to miss in a retrieval-augmented generation (RAG) design because the embedding index often looks like an immutable artifact. Product descriptions, inventory flags, regional eligibility, and delivery promises are mutable records. A document chunk that was relevant on Monday can be actively misleading on Tuesday.\n\nI treat each evaluation example as an event, not a row of text. It needs a query, the catalog snapshot identifier, the tenant or market, a timestamp, and graded judgments. The snapshot makes a failed result explainable: was the retriever weak, or did the test ask it to retrieve a product that no longer existed? That distinction matters for audit trails and for an exactly-once mindset in ingestion. Replaying an event should not silently create a second judgment or move a document into a newer snapshot.\n\nThe RAG paper by Lewis and colleagues (2020) describes retrieval as a separate memory component for generation, which is a useful boundary here: measure retrieval before a language model has a chance to hide missing evidence behind fluent prose.\n\nStart with the failure modes that the set must expose. For product search, I use four slices: exact identifiers such as SKU and model number; natural-language needs such as “quiet red kettle”; policy-sensitive constraints such as “available in Germany”; and freshness probes for newly added, changed, and retired products. Each slice gets its own recall and ranking thresholds. One aggregate number is not a decision rule.\n\nThe architecture follows from those slices. Keep a canonical product record in a transactional store, emit an outbox event for every meaningful change, and materialize searchable chunks with a deterministic `(product_id, revision, chunk_index)` key. A vector index can serve semantic candidates, while a lexical index catches identifiers and rare attributes. A final filter checks market and availability against the revision recorded in the candidate. This costs an extra read, but it prevents stale metadata from becoming a customer-facing promise. In practice, that filter also gives reconciliation a clear ledger: the candidate says which revision it saw, the catalog says which revision is currently sellable, and the evaluator can classify the mismatch instead of counting it as an unexplained ranking miss. If an event is delivered twice, the revision key and a uniqueness constraint let the indexer acknowledge the second delivery without creating a duplicate chunk; if events arrive out of order, the consumer compares revisions before replacing the searchable document. Those details are mundane until a sale depends on them.\n\nFreshness wins or the score is noise.\n\nHere is the small part I make deterministic in Go. The hash is an idempotency key for a chunk revision, not a substitute for a database constraint.\n\n```\npackage eval\n\nimport (\n    \"crypto/sha256\"\n    \"encoding/hex\"\n    \"fmt\"\n)\n\ntype ProductChunk struct {\n    ProductID string\n    Revision  int64\n    Index     int\n    Text      string\n}\n\nfunc ChunkKey(c ProductChunk) string {\n    material := fmt.Sprintf(\"%s:%d:%d:%s\", c.ProductID, c.Revision, c.Index, c.Text)\n    sum := sha256.Sum256([]byte(material))\n    return hex.EncodeToString(sum[:])\n}\n```\n\nThe test data should resemble the catalog's clock. I keep a small, hand-reviewed set for every change class, then add sampled production queries with personally identifying data removed. For each query, the expected set records acceptable product IDs and an expiry policy; judgments are graded, because “same product family” is not equivalent to “exact variant.”\n\n| Slice | Mutation | What it catches | Useful metric | \n|---|---|---|---|\n| New item | Published after the previous index build | Refresh lag | Recall@10 by age bucket | \n| Edited attribute | Size, color, or compliance text changed | Mixed revisions | Revision-consistency rate | \n| Retirement | Item removed or blocked in a market | Ghost results | Invalid-result rate | \n| Identifier | SKU or model query | Tokenization loss | MRR for exact match | \n| Ambiguous need | Short natural-language query | Chunk boundaries | nDCG@10 | \n\nThe important number is not only recall. Track the age of the newest indexed revision returned for a query, and alert when the p95 exceeds the product promise. I also record the index build ID and retriever configuration with every run. When a score moves, that metadata lets an engineer reproduce the result instead of arguing from screenshots.\n\nRun the matrix in CI for chunking changes, in staging against a frozen snapshot, and continuously against a rolling window of recent events. A canary should compare both relevance and freshness violations; promoting a model because nDCG rose while retired products increased is a correctness regression. For payment-adjacent catalogs or regulated claims, retain the judgment and revision trail according to the applicable retention policy, and have compliance approve what may be logged.\n\nThe catch is operational cost. Maintaining snapshots, graded labels, and dual lexical/vector retrieval takes more storage and review time than a single static benchmark. It is not suitable when the catalog is tiny, changes rarely, and a human reviews every result; a simpler lexical index and a weekly smoke set may be the better engineering choice. Stick with a static benchmark when you are measuring a one-off prototype, but do not use that score to promise production freshness.\n\nI am not sure one universal freshness threshold exists: delivery promises differ by market and category. Your mileage may vary. The threshold should come from the user-visible policy, then be encoded in the evaluation set so it cannot drift unnoticed.", "url": "https://wpnews.pro/news/e-commerce-product-search-retrieval-go-s-5-freshness-checks-for-evaluation-sets", "canonical_source": "https://dev.to/irvincole5861/e-commerce-product-search-retrieval-gos-5-freshness-checks-for-evaluation-sets-23f7", "published_at": "2026-11-23 23:36:22+00:00", "updated_at": "2026-11-23 23:42:26.381219+00:00", "lang": "en", "topics": ["ai-search", "ai-tools"], "entities": ["Go", "Lewis et al. RAG paper (2020)"], "also_reported_by": [], "takeaway": "Tie each retrieval evaluation example to a catalog snapshot ID and timestamp, and have the final filter verify market and availability against the revision recorded in each candidate so stale metadata is classified as a mismatch rather than an unexplained ranking miss.", "recommendation": {"advice": "Version evaluation queries against catalog snapshots and filter candidates by their recorded revision before serving, so stale or retired products are caught and mismatches are explainable.", "playbook": "rag-retrieval", "playbook_url": "https://wpnews.pro/playbooks/rag-retrieval"}, "alternates": {"html": "https://wpnews.pro/news/e-commerce-product-search-retrieval-go-s-5-freshness-checks-for-evaluation-sets", "markdown": "https://wpnews.pro/news/e-commerce-product-search-retrieval-go-s-5-freshness-checks-for-evaluation-sets.md", "text": "https://wpnews.pro/news/e-commerce-product-search-retrieval-go-s-5-freshness-checks-for-evaluation-sets.txt", "jsonld": "https://wpnews.pro/news/e-commerce-product-search-retrieval-go-s-5-freshness-checks-for-evaluation-sets.jsonld"}}