Inferensys

Prompt

Price Range Expansion Prompt for E-Commerce Retrieval

A practical prompt playbook for normalizing user price expressions into structured currency ranges for e-commerce retrieval pipelines.
Developer building retrieval augmentation on laptop, document chunks and embeddings visualized, technical workspace.
PROMPT PLAYBOOK

When to Use This Prompt

Learn when to apply price range normalization, what inputs it requires, and when to avoid it.

This prompt is designed for the pre-retrieval stage of an e-commerce search pipeline. Its job is to intercept natural language queries that contain price intent—such as 'wireless headphones under $100', 'cheap standing desks', or 'premium leather boots'—and transform the user's price expression into a structured JSON object with explicit min_price, max_price, and currency_code fields. This structured output can then be directly translated into metadata filter clauses for vector databases like Pinecone, Weaviate, or Elasticsearch, enabling hybrid retrieval that combines semantic relevance with precise price constraints. The primary user is a search engineer, RAG developer, or platform architect who already has a product catalog indexed with price metadata and needs to bridge the gap between human price language and machine-readable filters.

Use this prompt when your system meets three conditions: (1) your product catalog contains numeric price fields and currency codes, (2) users express budget constraints in free-text search queries, and (3) your retrieval pipeline supports metadata filtering alongside vector or keyword search. The prompt handles explicit ranges ('between $50 and $200'), comparative expressions ('less than $30', 'above $500'), and symbolic price tiers ('affordable', 'budget', 'premium', 'luxury') by mapping them to configurable numeric thresholds. It also normalizes currency symbols and codes ($, USD, EUR, GBP) into ISO 4217 format. However, do not use this prompt for non-price numerical ranges (e.g., 'laptops with 16GB RAM', 'TVs over 65 inches'), temporal expressions ('released after 2023'), or queries that contain no pricing intent whatsoever. Running price extraction on every query wastes tokens and latency budget without adding value.

Before deploying, define your symbolic price tier mappings in the [TIER_DEFINITIONS] placeholder. What 'budget' means for electronics differs from what it means for furniture, so consider category-specific tier definitions if your catalog spans diverse product types. Also implement a pre-check: if the query contains no currency symbols, price-related keywords, or tier language, skip this prompt entirely and pass the raw query to retrieval. For production, pair this prompt with a lightweight classifier or keyword gate to avoid unnecessary LLM calls. The next section provides the copy-ready prompt template you can adapt and test against your own catalog's price distribution.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Price Range Expansion Prompt works, where it fails, and the operational prerequisites for production use.

01

Good Fit: Explicit Price Language

Use when: User queries contain clear price signals like 'under $50', 'between $100-200', 'cheap', 'premium', or 'affordable'. The prompt maps these to concrete min/max bounds and currency codes. Guardrail: Validate that the input contains at least one price-related token before invoking expansion to avoid hallucinated ranges on non-price queries.

02

Bad Fit: Subjective Value Judgments

Avoid when: Queries express purely subjective value like 'worth it', 'good deal', or 'overpriced' without any numeric anchor. These require market context and historical pricing data, not simple range expansion. Guardrail: Route subjective value queries to a separate market intelligence prompt or return an explicit 'insufficient numeric signal' flag rather than guessing a range.

03

Required Input: Currency Context

Risk: Queries like 'under 50' without a currency code produce ambiguous ranges. The model may default to USD, causing incorrect filters in multi-currency catalogs. Guardrail: Always provide a [DEFAULT_CURRENCY] parameter and a [SUPPORTED_CURRENCIES] list. If the query omits currency, inject the default and log the assumption for downstream audit.

04

Required Input: Catalog Price Distribution

Risk: Terms like 'affordable' or 'luxury' are relative to the catalog. Without distribution context, the model applies arbitrary thresholds that may mismatch inventory. Guardrail: Supply optional [PRICE_PERCENTILES] or [CATEGORY_BENCHMARKS] so the prompt can anchor qualitative tiers to actual catalog data rather than generic assumptions.

05

Operational Risk: Symbolic Pricing Thresholds

Risk: Users say 'under $100' but psychologically accept results at $99.99 while rejecting $100.01. Strict boundary interpretation can exclude relevant items or include unwanted ones. Guardrail: Implement a configurable [BOUNDARY_TOLERANCE] parameter (e.g., ±2%) and return both strict and relaxed ranges so the retrieval layer can decide on fuzzy matching behavior.

06

Operational Risk: Multi-Currency Inconsistency

Risk: A query in USD against a catalog with EUR and GBP listings produces incorrect comparisons if ranges aren't converted. Exchange rate staleness introduces silent errors. Guardrail: Require a [CONVERSION_RATE_SOURCE] and [RATE_FRESHNESS_THRESHOLD]. If rates are stale beyond the threshold, return an error flag rather than applying outdated conversions.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt that normalizes price expressions into explicit currency ranges and metadata filter clauses for e-commerce retrieval systems.

This template converts user-facing price language—such as 'under $50', 'between $100 and $200', 'affordable', or 'premium'—into structured price range outputs that your retrieval system can use as filter clauses. The prompt handles currency code extraction, symbolic pricing tiers, and boundary disambiguation. Replace each square-bracket placeholder with your application's specific values before sending the prompt to the model.

text
You are a price range normalization engine for an e-commerce retrieval system. Your job is to convert natural language price expressions into explicit, machine-readable price ranges with currency codes and filter-ready boundary operators.

## INPUT
User query: [USER_QUERY]

## CONTEXT
- Default currency code: [DEFAULT_CURRENCY_CODE]
- Available symbolic pricing tiers: [SYMBOLIC_TIERS]
- Maximum allowed price value: [MAX_PRICE]
- Minimum allowed price value: [MIN_PRICE]

## OUTPUT_SCHEMA
Return a JSON object with the following structure:
{
  "price_constraints": [
    {
      "currency": "string (ISO 4217 code)",
      "min_amount": number | null,
      "max_amount": number | null,
      "min_operator": "gte" | "gt" | null,
      "max_operator": "lte" | "lt" | null,
      "symbolic_tier": "string | null",
      "confidence": number (0.0 to 1.0),
      "source_phrase": "string (the original text that produced this constraint)"
    }
  ],
  "original_expression": "string",
  "detected_currency": "string | null",
  "requires_clarification": boolean,
  "clarification_question": "string | null",
  "assumptions": ["string"]
}

## CONSTRAINTS
1. If the query contains an explicit currency symbol or code (e.g., $, USD, EUR, £), use that currency. Otherwise, use the default currency code.
2. For symbolic expressions like 'affordable', 'cheap', 'premium', 'luxury', 'mid-range', or 'budget', map them to the provided symbolic pricing tiers. If no tier matches, set symbolic_tier to null and estimate numeric bounds with lower confidence.
3. For 'under X' or 'less than X', set max_amount to X and max_operator to 'lt'. Set min_amount to [MIN_PRICE] and min_operator to 'gte'.
4. For 'over X' or 'more than X', set min_amount to X and min_operator to 'gt'. Set max_amount to [MAX_PRICE] and max_operator to 'lte'.
5. For 'between X and Y' or 'X to Y', set both min_amount and max_amount. Use 'gte' for min_operator and 'lte' for max_operator unless the query explicitly says 'between X and Y exclusive'.
6. For exact prices like 'exactly $50' or '$50', set min_amount and max_amount to the same value with 'gte' and 'lte' operators.
7. If the query contains multiple price constraints (e.g., 'under $50 or over $200'), produce multiple entries in the price_constraints array.
8. If the price expression is ambiguous (e.g., 'around $100' without a tolerance), set requires_clarification to true and provide a clarification_question.
9. If no price expression is detected, return an empty price_constraints array and set requires_clarification to false.
10. List all assumptions you made in the assumptions array, including default currency application and symbolic tier mappings.
11. Set confidence based on how explicit the price expression is: explicit numbers with clear operators = 0.95+, symbolic tiers = 0.7-0.85, vague expressions = 0.5-0.7.

## EXAMPLES
Query: "show me headphones under $100"
Default currency: USD
Output:
{
  "price_constraints": [
    {
      "currency": "USD",
      "min_amount": 0,
      "max_amount": 100,
      "min_operator": "gte",
      "max_operator": "lt",
      "symbolic_tier": null,
      "confidence": 0.98,
      "source_phrase": "under $100"
    }
  ],
  "original_expression": "under $100",
  "detected_currency": "USD",
  "requires_clarification": false,
  "clarification_question": null,
  "assumptions": ["Applied default minimum price of 0"]
}

Query: "affordable running shoes"
Default currency: EUR
Symbolic tiers: {"budget": {"min": 0, "max": 50}, "affordable": {"min": 20, "max": 80}, "mid-range": {"min": 50, "max": 150}, "premium": {"min": 100, "max": 300}, "luxury": {"min": 200, "max": 9999}}
Output:
{
  "price_constraints": [
    {
      "currency": "EUR",
      "min_amount": 20,
      "max_amount": 80,
      "min_operator": "gte",
      "max_operator": "lte",
      "symbolic_tier": "affordable",
      "confidence": 0.8,
      "source_phrase": "affordable"
    }
  ],
  "original_expression": "affordable",
  "detected_currency": null,
  "requires_clarification": false,
  "clarification_question": null,
  "assumptions": ["Applied default currency EUR", "Mapped 'affordable' to tier with bounds 20-80 EUR"]
}

## RISK_LEVEL
Medium. Incorrect price range extraction can produce irrelevant search results and degrade user trust. Validate outputs before applying as database filter clauses.

To adapt this template, replace the placeholders with your application's runtime values. [USER_QUERY] should contain the raw user input. [DEFAULT_CURRENCY_CODE] is your store's primary currency in ISO 4217 format (e.g., 'USD', 'EUR', 'GBP'). [SYMBOLIC_TIERS] should be a JSON object mapping your pricing tier names to min/max bounds—this is critical for e-commerce sites that use tiered pricing language in navigation or filters. [MAX_PRICE] and [MIN_PRICE] define the absolute boundaries of your catalog to prevent nonsensical ranges. If your application supports multi-currency, ensure the detected_currency field is used downstream to select the correct price index. For production use, always validate the output JSON against the schema before constructing database filter clauses, and log any outputs where confidence falls below 0.7 for human review.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Price Range Expansion Prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to check the input at runtime before template rendering.

PlaceholderPurposeExampleValidation Notes

[USER_QUERY]

The raw natural language query containing a price expression to normalize

I need a standing desk under $500

Non-empty string; max 2000 chars; must contain at least one price-indicative token (dollar sign, currency word, or numeric range)

[DEFAULT_CURRENCY]

The ISO 4217 currency code to assume when the query omits an explicit currency symbol or name

USD

Must match ^[A-Z]{3}$; validate against allowed currency list for the storefront; reject if null when multi-currency storefront is active

[STORE_CURRENCIES]

The set of ISO 4217 currency codes the storefront supports, used to disambiguate currency symbols

["USD", "CAD", "EUR"]

Non-empty JSON array of 3-letter codes; each code must pass ISO 4217 validation; used to resolve ambiguous $ symbol to correct currency

[PRICE_PRECISION]

The number of decimal places to use in output price boundaries, driven by currency subunit rules

2

Integer 0-4; 0 for JPY/KRW; 2 for USD/EUR/GBP; 3 for BHD/KWD; derived from currency config, not user input

[INCLUSIVE_BOUNDARIES]

Whether generated ranges should use inclusive (>=, <=) or exclusive (>, <) boundary operators for filter construction

Boolean; true for most e-commerce use cases; false when strict less-than/greater-than semantics are required by the search backend

[MAX_PRICE_CEILING]

An upper safety bound to cap expanded ranges, preventing absurdly high price filters from a malformed or adversarial query

100000

Positive number; set to store's maximum listed item price plus 20% buffer; reject any generated range whose upper bound exceeds this value

[SYMBOLIC_THRESHOLD_MAP]

A mapping of symbolic price words to concrete ranges, tuned to the store's pricing distribution

{"affordable": [0, 50], "cheap": [0, 25], "premium": [200, null], "luxury": [500, null]}

JSON object; keys are lowercase strings; values are [min, max] tuples where null means unbounded; validate that no range contradicts store inventory price distribution

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the price range expansion prompt into an e-commerce retrieval pipeline with validation, currency handling, and fallback logic.

The price range expansion prompt is designed as a pre-retrieval transformation step. It takes a raw user query containing price language and normalizes it into a structured JSON object with explicit min_price, max_price, currency_code, and operator fields. This structured output is not the final answer to the user—it is a machine-readable filter clause that your application should inject into a downstream search or vector database query. The prompt should be called before any retrieval call, and its output should be validated before being used to construct filter predicates.

To wire this into a production pipeline, wrap the prompt call in a lightweight service function. The function should accept the user's raw query string and an optional default_currency parameter (e.g., 'USD'). On success, parse the JSON response and validate that min_price and max_price are non-negative numbers, that min_price <= max_price when both are present, and that currency_code is a valid ISO 4217 code. If the model returns a null range (indicating no price constraint was detected), skip the price filter entirely. If validation fails, log the raw output and fall back to an unfiltered retrieval rather than applying a broken filter. For multi-currency scenarios, your service should maintain a mapping of supported currencies and either convert the range to the catalog's base currency using current exchange rates or reject unsupported currencies with a clear user-facing message.

For observability, log every prompt call with the input query, the raw model output, the validated filter object, and whether the filter was applied or discarded. This trace data is essential for debugging retrieval failures—if a user complains about missing products, you need to know whether the price filter excluded them. Set up an eval harness that tests the prompt against a golden set of queries like 'under $50', 'between 100 and 200 euros', 'affordable headphones', and 'cheap'. For each test case, assert the correct min_price, max_price, and currency_code. Pay special attention to edge cases: queries with no price language should return null; symbolic terms like 'affordable' or 'premium' should map to reasonable ranges based on your product catalog's price distribution; and malformed inputs like 'between $50' should either be caught by validation or produce a conservative filter. Run these evals on every prompt change before deployment.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the model response when normalizing price expressions into concrete currency ranges.

Field or ElementType or FormatRequiredValidation Rule

price_ranges

Array of objects

Must contain at least one element. Array must be parseable as valid JSON.

price_ranges[].min_amount

Number or null

Must be a non-negative float. Set to null only if the range has no lower bound (e.g., 'under $50').

price_ranges[].max_amount

Number or null

Must be a non-negative float. Set to null only if the range has no upper bound (e.g., 'over $100').

price_ranges[].currency_code

String (ISO 4217)

Must match regex ^[A-Z]{3}$. Default to [DEFAULT_CURRENCY] if no currency is detected in the query.

price_ranges[].original_expression

String

Must be a non-empty substring from [USER_QUERY]. Used for traceability.

price_ranges[].is_approximate

Boolean

Must be true if the query contains hedges like 'around', 'about', 'roughly', or 'affordable'. Otherwise false.

price_ranges[].confidence

Number (0.0-1.0)

If present, must be a float between 0.0 and 1.0. Required when is_approximate is true. Represents model confidence in the numeric boundary interpretation.

unmapped_expressions

Array of strings

If present, each element must be a substring from [USER_QUERY] that could not be mapped to a numeric range. If all expressions are mapped, this field should be an empty array or omitted.

PRACTICAL GUARDRAILS

Common Failure Modes

Price range expansion fails silently in ways that break retrieval precision, produce empty result sets, or surface irrelevant products. These are the most common failure modes and the guardrails that catch them before they reach production.

01

Symbolic Price Terms Map to Wrong Ranges

Risk: Terms like 'affordable', 'premium', 'budget', or 'luxury' carry implicit price bands that vary by category, region, and brand. A single global mapping produces absurd results—'affordable' might mean $20 for headphones but $500 for laptops. Guardrail: Require a category context input. If category is unknown, generate multiple candidate ranges with explicit assumptions and ask the retrieval layer to rank or merge results. Never ship a single hardcoded symbolic-to-numeric mapping without category anchoring.

02

Currency Ambiguity Produces Cross-Currency Mismatches

Risk: A query for 'under $50' without a currency context may retrieve products priced in CAD, AUD, or USD, producing false matches when the user meant USD. Worse, the prompt may silently default to a currency that doesn't match the product catalog. Guardrail: Always require an explicit currency code input. If the user doesn't provide one, extract it from session locale, catalog metadata, or query context. Validate that the resolved currency exists in the target product index before executing retrieval.

03

Inclusive vs. Exclusive Boundary Confusion

Risk: Queries like 'under $50' or 'above $100' are ambiguous about whether the boundary value is included. A prompt that defaults to inclusive on both sides will return $50.00 products for 'under $50' queries, frustrating users. Guardrail: Define explicit operator semantics in the prompt template. Map 'under' to strictly less than, 'up to' to less than or equal, 'over' to strictly greater than, and 'between X and Y' to inclusive on both ends unless the user says 'strictly between'. Log boundary operator decisions for audit.

04

Missing Upper or Lower Bound Creates Unbounded Filters

Risk: A query like 'laptops over $1000' produces a filter with no upper bound, potentially returning enterprise server hardware priced at $50,000. Similarly, 'under $20' with no lower bound may return free items, samples, or placeholder SKUs priced at $0. Guardrail: Apply sane default bounds based on category context when one boundary is missing. For 'over X', cap at a category-appropriate ceiling. For 'under X', floor at a non-zero minimum. Log when defaults are applied so the retrieval layer can adjust or surface the assumption.

05

Price Range Conflicts with Other Filter Constraints

Risk: The prompt expands a price range in isolation, but the retrieval system also applies category, brand, or availability filters. The combined constraints may produce zero results even though the price range alone is valid. The failure is silent—the prompt succeeded, but retrieval returned nothing. Guardrail: Generate the price range as one filter clause among many. Include a post-retrieval check: if result count is zero, relax the price range by a configurable margin and retry. Log the relaxation step so relevance teams can tune the margin.

06

Multi-Currency Catalogs Produce Inconsistent Comparisons

Risk: When a product catalog stores prices in multiple currencies, a single expanded range in one currency cannot be directly compared to products priced in another. The prompt may produce a USD range that the retrieval layer applies naively to EUR-priced products, returning garbage results. Guardrail: The prompt output must include the resolved currency code. The retrieval layer must either convert all prices to a common currency before filtering or restrict the query to products in the resolved currency. If conversion is used, include the exchange rate source and timestamp in retrieval metadata.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of the price range expansion output before integrating it into a production retrieval pipeline. Each criterion should be tested with a representative set of queries covering exact boundaries, symbolic pricing, multi-currency, and edge cases.

CriterionPass StandardFailure SignalTest Method

Currency Code Extraction

ISO 4217 currency code is correctly identified from explicit symbols ($, €, £) or text (USD, EUR) and placed in the [CURRENCY] field.

Missing currency code, incorrect code for the symbol, or null when a currency is clearly implied.

Run 20 queries with explicit and implicit currency signals. Assert [CURRENCY] matches expected ISO 4217 code.

Price Boundary Parsing

Min and max values in [MIN_PRICE] and [MAX_PRICE] are exact integers or floats matching the query. 'Under $50' produces max=50, min=null. 'Over $100' produces min=100, max=null.

Off-by-one errors on boundaries, inverted min/max, or failure to handle 'under' vs. 'up to' semantics.

Test boundary queries: 'under $50', '$50 and under', 'over $100', 'at least $100'. Assert boundary values and null handling.

Range Expression Handling

Explicit ranges like 'between $100 and $200' produce min=100, max=200 with inclusive boundaries noted in [BOUNDARY_INCLUSIVE]. 'Around $50' produces a reasonable tolerance range.

Range endpoints swapped, missing one endpoint, or failure to expand vague range modifiers like 'around' or 'approximately'.

Test 15 range queries with explicit and vague modifiers. Assert min <= max and tolerance is within 20% for vague terms.

Symbolic Pricing Normalization

Terms like 'affordable', 'cheap', 'premium', 'luxury', 'budget' are mapped to concrete price ranges appropriate for the product category in [CATEGORY].

Symbolic term left unmapped, mapped to a range that contradicts the category context, or mapped to a single fixed value.

Test 10 symbolic pricing queries across 3 product categories. Assert ranges are category-appropriate and documented in [RANGE_RATIONALE].

Multi-Currency Scenario Handling

When query contains multiple currencies or requests conversion, the output includes a [CONVERSION_RATE] field with the rate used and a [CONVERTED_RANGE] field.

Silent currency mixing, missing conversion rate, or conversion applied without noting the rate source.

Test 5 multi-currency queries. Assert [CONVERSION_RATE] is populated, [CONVERTED_RANGE] is present, and [RATE_SOURCE] is documented.

Null Boundary Handling

Open-ended queries like 'under $50' correctly set [MAX_PRICE]=50 and [MIN_PRICE]=null. 'Over $200' sets [MIN_PRICE]=200 and [MAX_PRICE]=null. No sentinel values like 0 or 999999 used.

Sentinel values substituted for null, null boundaries treated as 0 in downstream logic, or open-ended ranges rejected as invalid.

Test 10 open-ended queries. Assert null appears where appropriate and no magic numbers are substituted.

Output Schema Compliance

Output is valid JSON matching the defined schema with all required fields present: [CURRENCY], [MIN_PRICE], [MAX_PRICE], [BOUNDARY_INCLUSIVE], [ORIGINAL_EXPRESSION], [RANGE_RATIONALE].

Missing required fields, extra fields not in schema, wrong types (string instead of number), or malformed JSON.

Validate all outputs against the JSON schema. Assert 100% parse success and 100% required field presence across 50 test queries.

Edge Case: Zero and Free

Queries for 'free' or '$0' produce min=0, max=0 with [BOUNDARY_INCLUSIVE]=true for both. No null or negative values.

Free interpreted as null price, negative price generated, or range incorrectly expanded to include paid items.

Test queries: 'free', '$0', 'free shipping items'. Assert min=0, max=0, and no paid-item contamination in rationale.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single currency. Remove strict output schema requirements and use a simple key-value format. Test with 10-15 common price expressions like 'under $50', 'cheap', 'premium', and 'between $100-200'.

code
Convert the following price expression into a min and max price range in USD:

Price expression: [PRICE_EXPRESSION]

Return JSON: {"min": number|null, "max": number|null, "currency": "USD"}

Watch for

  • Symbolic terms like 'affordable' or 'luxury' producing wildly different ranges across runs
  • Missing null handling when no upper or lower bound exists
  • Currency symbols in the input being ignored
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.