# E-commerce Product Search Retrieval: Go's 5 Freshness Checks for Evaluation Sets

> Source: <https://dev.to/irvincole5861/e-commerce-product-search-retrieval-gos-5-freshness-checks-for-evaluation-sets-23f7>
> Published: 2026-11-23 23:36:22+00:00

**Recommendation:** 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.
More in the playbook "Retrieval and RAG": <https://wpnews.pro/playbooks/rag-retrieval>

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.

In 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.

I 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.

The 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.

Start 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.

The 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.

Freshness wins or the score is noise.

Here 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.

```
package eval

import (
    "crypto/sha256"
    "encoding/hex"
    "fmt"
)

type ProductChunk struct {
    ProductID string
    Revision  int64
    Index     int
    Text      string
}

func ChunkKey(c ProductChunk) string {
    material := fmt.Sprintf("%s:%d:%d:%s", c.ProductID, c.Revision, c.Index, c.Text)
    sum := sha256.Sum256([]byte(material))
    return hex.EncodeToString(sum[:])
}
```

The 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.”

| Slice | Mutation | What it catches | Useful metric | 
|---|---|---|---|
| New item | Published after the previous index build | Refresh lag | Recall@10 by age bucket | 
| Edited attribute | Size, color, or compliance text changed | Mixed revisions | Revision-consistency rate | 
| Retirement | Item removed or blocked in a market | Ghost results | Invalid-result rate | 
| Identifier | SKU or model query | Tokenization loss | MRR for exact match | 
| Ambiguous need | Short natural-language query | Chunk boundaries | nDCG@10 | 

The 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.

Run 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.

The 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.

I 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.
