GLOSSARY

Search Scripting

Search scripting lets you inject small pieces of code into the search pipeline. Use it for custom rewrites or scoring rules you can’t express with configuration.

What is Search Scripting?

Search scripting is the use of lightweight code (safe, sandboxed) to transform queries, compute features, or adjust scores inside the search stack. It complements standard settings (fields, boosts, synonyms) with logic that runs at ingest, query, or rank time.

How It Works (quick)

  • Ingest-time: Compute derived attributes (e.g., age-in-days, size buckets).
  • Query-time: Conditional rewrites, locale fixes, campaign toggles, price/size guards.
  • Rank-time: Add small, capped boosts (e.g., decay by age, margin-aware nudges).
  • Controls: Feature flags, timeouts, memoization/cache, and versioned configs.

Why It Matters in E-commerce

  • Agility: Ship targeted rules without reindexing.
  • Business fit: Encode nuanced policies (availability windows, size-in-stock, clearance).
  • Experimentation: A/B test micro-logic safely.

Best Practices

  • Keep scripts deterministic, pure, and fast (< a few ms each).
  • Cap influence so scripts can’t outrank clear relevance.
  • Sandbox and rate-limit; validate inputs; avoid remote calls in the hot path.
  • Prefer precomputed features when possible; script only the glue.
  • Log & explain: record which scripts fired and their deltas.

Challenges

  • Latency creep, non-reproducible results if unversioned, and security risks without sandboxing.

Examples

  • Age-decay boost for “new arrivals” with a hard cap.
  • Category-conditional bump for waterproof in trail running.
  • Query-time guard: disable fuzziness when query looks like a SKU.

Summary

Use search scripting as a precise scalpel—fast, safe, and capped—to add context-aware tweaks without bloating the index or harming precision.

FAQ

Script vs LTR? LTR learns a scoring function; scripts apply small rules and guardrails.

Does scripting affect SEO pages? It’s an internal search concern, not public HTML, so no SEO risk.