This prompt is designed for e-commerce search engineers who need to extract structured price constraints from natural language shopping queries before they hit the retrieval engine. The core job-to-be-done is converting user expressions like 'wireless headphones under $100', 'laptops between $500 and $1000', or 'cheap running shoes' into machine-readable filter clauses that a search backend can execute. It belongs in the query understanding stage of a hybrid search pipeline, sitting between the raw user input and the retrieval step, and it works alongside other metadata extraction prompts that handle categories, brands, ratings, and other facets. The ideal user is a platform engineer or search relevance developer who already has a search index with indexed price fields and needs a reliable way to bridge the gap between how users talk about price and how the search API expects to receive price filters.
Prompt
Price Range Filter Generation Prompt Template

When to Use This Prompt
Determine whether the Price Range Filter Generation prompt is the right tool for your query understanding pipeline and when to choose a different approach.
Use this prompt when your search interface accepts free-text queries that may contain price constraints, when your product catalog has numeric price fields that can be filtered, and when you need consistent, validated filter output that downstream systems can consume without additional parsing. The prompt handles several price expression patterns: explicit ranges ('$20 to $50'), comparisons ('under $30', 'above $200', 'less than $15'), single thresholds ('around $100'), and qualitative price signals ('cheap', 'affordable', 'premium', 'luxury'). It also detects currency symbols and codes, normalizes them to a configured default currency, and interprets boundary inclusivity—whether 'under $50' means strictly less than 50 or less-than-or-equal-to 49.99, depending on your business rules. The output is a structured filter object with fields for operator, value, currency, and boundary type, ready to be translated into your search backend's filter DSL.
Do not use this prompt when price constraints are already captured through structured UI controls like sliders, dropdowns, or input masks. If users select price ranges from a faceted interface, you already have structured data and adding an LLM extraction step adds latency and cost without benefit. Similarly, avoid this prompt for non-ecommerce use cases where 'price' has a different semantic meaning—financial data queries, invoice line items, or cost analysis questions require different extraction logic. The prompt is also not a substitute for proper price indexing: if your search backend cannot filter by numeric price ranges, no amount of query understanding will help. Finally, for queries that combine price with complex boolean logic across multiple facets ('Sony or Bose headphones under $100 but not refurbished'), use this prompt in sequence with the Combined AND/OR Filter Logic prompt rather than expecting it to handle cross-facet operator precedence on its own.
Use Case Fit
Where the Price Range Filter Generation prompt works well, where it fails, and the operational prerequisites for production use.
Good Fit: Explicit Shopping Queries
Use when: the user query contains explicit price language like 'under $50', 'between $20 and $100', 'cheap', 'premium', or 'budget-friendly'. The prompt excels at extracting structured numerical ranges from these signals. Guardrail: Pair with a query intent classifier to ensure the prompt only fires for transactional or comparison shopping intents, not informational queries.
Bad Fit: Implied or Subjective Value
Avoid when: the query relies on subjective value judgments without numerical anchors, such as 'worth the money', 'good value', or 'affordable for a family'. The model will hallucinate arbitrary ranges. Guardrail: Route these queries to a review queue or use a separate prompt that maps subjective tiers to your platform's predefined price bands based on product category context.
Required Inputs: Currency and Locale Context
Risk: Without explicit currency and locale context, the model defaults to USD and may misinterpret symbols like '$' or fail to normalize '€50' correctly. Guardrail: Always inject the user's session currency, locale, and market as mandatory template variables. Validate the output currency code against the expected input before passing the filter to your search backend.
Operational Risk: Boundary Interpretation Drift
Risk: 'Under $50' could mean price < 50 or price <= 49.99. Inconsistent boundary interpretation causes off-by-one errors in filtered results and missed products. Guardrail: Define a strict boundary policy in the system prompt (e.g., 'under' means strict less-than, 'up to' means less-than-or-equal). Add an eval harness that tests boundary edge cases for every deployment.
Operational Risk: Missing Price Context
Risk: The user query may contain no price signal at all. The prompt must return an empty or null filter, not a guessed range. Guardrail: Instruct the model to return a structured null or empty filter object when no price constraint is detected. Validate this behavior in your test suite to prevent silent filter injection.
Integration Risk: Filter Syntax Mismatch
Risk: The generated range object may not match your search backend's exact DSL (e.g., Elasticsearch range vs. Pinecone metadata filter syntax). Guardrail: Use a strict JSON output schema with a post-generation validation layer that maps the model's output to your backend's required format. Reject and retry any output that fails schema validation.
Copy-Ready Prompt Template
A reusable prompt template for extracting structured price range filters from natural language shopping queries, ready to adapt and integrate into your search pipeline.
This template provides a production-ready prompt for converting user queries like 'wireless headphones under $100' or 'laptops between $500 and $1000' into structured price constraints. The prompt is designed to handle range expressions, comparison operators, and currency-aware thresholds while producing a consistent JSON output that your search backend can consume directly. Replace each square-bracket placeholder with your application's specific values before use.
textYou are a price filter extraction system for an e-commerce search engine. Your job is to analyze a user's shopping query and extract any price constraints into a structured JSON object. [CONTEXT] - Supported currency: [CURRENCY_CODE] - Default currency if none specified: [DEFAULT_CURRENCY] - Maximum allowed price value: [MAX_PRICE] - Treat unspecified boundaries as: [BOUNDARY_DEFAULT] [INPUT] User query: [USER_QUERY] [OUTPUT_SCHEMA] Return ONLY a valid JSON object with this exact structure: { "price_filter": { "detected": boolean, "currency": string | null, "min_price": number | null, "max_price": number | null, "min_inclusive": boolean, "max_inclusive": boolean, "expression_type": "range" | "less_than" | "greater_than" | "exact" | "none", "original_phrase": string | null, "confidence": number } } [CONSTRAINTS] 1. If no price information is detected, set "detected": false and all other fields to null or their zero values. 2. For "under $X" or "less than $X", set max_price to X and max_inclusive to false. 3. For "over $X" or "more than $X", set min_price to X and min_inclusive to false. 4. For "between $X and $Y", set both boundaries with min_inclusive and max_inclusive both true. 5. For "around $X" or "approximately $X", set min_price to X*0.9 and max_price to X*1.1 with both inclusive. 6. Normalize all prices to the smallest currency unit (e.g., cents) as integers. 7. Set confidence between 0.0 and 1.0 based on how explicit the price constraint is. 8. If multiple price constraints conflict, extract only the most specific one and set confidence lower. 9. Ignore prices that appear to be product names, model numbers, or unrelated numbers. 10. Do not include any text outside the JSON object. [EXAMPLES] Query: "bluetooth speaker under 50 dollars" Output: {"price_filter":{"detected":true,"currency":"USD","min_price":null,"max_price":5000,"min_inclusive":false,"max_inclusive":false,"expression_type":"less_than","original_phrase":"under 50 dollars","confidence":0.95}} Query: "Samsung Galaxy S23" Output: {"price_filter":{"detected":false,"currency":null,"min_price":null,"max_price":null,"min_inclusive":false,"max_inclusive":false,"expression_type":"none","original_phrase":null,"confidence":1.0}} Query: "office chair between 200 and 400 EUR" Output: {"price_filter":{"detected":true,"currency":"EUR","min_price":20000,"max_price":40000,"min_inclusive":true,"max_inclusive":true,"expression_type":"range","original_phrase":"between 200 and 400 EUR","confidence":0.95}}
Before integrating this prompt into your application, verify that the output schema matches your search backend's filter interface. The examples use integer cents to avoid floating-point comparison issues, but you may need to adjust this for your system. Test the prompt against queries with ambiguous price language ('cheap', 'affordable', 'premium') to ensure your confidence thresholds align with your tolerance for false positives. For production use, add a post-extraction validation step that rejects filters where confidence falls below your configured threshold and falls back to a price-agnostic search.
Prompt Variables
Placeholders required by the Price Range Filter Generation prompt. Wire these into your application harness before sending the prompt to the model.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[USER_QUERY] | The raw natural language shopping query containing price intent | Show me wireless headphones under $100 | Required. Must be a non-empty string. Check for adversarial input and prompt injection before passing to the model. |
[CURRENCY] | ISO 4217 currency code for the target market | USD | Required. Must match /^[A-Z]{3}$/. Default to USD if not explicitly provided. Reject unsupported currencies at the application layer before model call. |
[CURRENCY_SYMBOL] | Localized currency symbol for display and parsing | $ | Optional. Derive from [CURRENCY] if null. Use for symbol-based extraction (e.g., '$50'). Validate that symbol matches currency code. |
[LOCALE] | BCP 47 locale tag for number formatting and decimal separator conventions | en-US | Required. Must match /^[a-z]{2}-[A-Z]{2}$/. Affects parsing of '1,000' vs '1.000'. Default to en-US if not provided. |
[OUTPUT_SCHEMA] | JSON Schema defining the expected filter output structure | {"type":"object","properties":{"min_price":{"type":"number"},"max_price":{"type":"number"},"operator":{"type":"string","enum":["between","gte","lte","eq"]},"is_negotiable":{"type":"boolean"}},"required":["operator"]} | Required. Must be valid JSON Schema. Validate with a schema parser before injection. Reject if schema contains unsupported keywords for the target model. |
[TAXONOMY_CATEGORIES] | List of known product categories for context-aware price range interpretation | ["electronics","headphones","wireless-audio"] | Optional. Array of strings. Use to disambiguate price expectations (e.g., '$5000 headphones' is plausible, '$5000 socks' is not). Pass empty array if unavailable. |
[ANCHOR_DATE] | ISO 8601 date string for resolving relative price references like 'on sale now' | 2025-03-15 | Optional. Use current UTC date if null. Required only when queries contain sale or temporal price language. Validate as valid ISO 8601 date. |
[MAX_RANGE_RATIO] | Maximum allowed ratio between min and max price to flag potential extraction errors | 100 | Optional. Float. Default 100. If extracted max/min > this value, flag for human review. Prevents '$10 to $10,000' misinterpretation from a query like 'cheap or expensive headphones'. |
Implementation Harness Notes
How to wire the price range filter prompt into a production e-commerce search pipeline with validation, retries, and logging.
The price range filter prompt is not a standalone widget—it is a structured extraction step inside a search query understanding pipeline. In production, the user's raw query arrives at an API gateway, passes through normalization, and then hits this prompt to extract price constraints before the system constructs the final search request. The prompt's output must be a machine-readable JSON object containing min_price, max_price, currency, operator, and confidence fields, not free text. This contract allows downstream services to merge extracted price filters with other metadata constraints, apply business rules (e.g., default currency, maximum range width), and build the final Elasticsearch or vector search query without parsing ambiguity.
Wire the prompt into your application with a thin extraction service that handles the full lifecycle: input assembly, model invocation, output validation, retry logic, and observability. On input assembly, inject the user's raw query into the [USER_QUERY] placeholder and set [DEFAULT_CURRENCY] from the user's session or store configuration. After receiving the model response, validate the JSON schema strictly—reject any output where min_price exceeds max_price, where currency is not in your allowed list, or where confidence falls below a configured threshold (start at 0.7 and tune based on false-positive rates). On validation failure, implement a single retry with the validation error message appended to the prompt as additional context; if the retry also fails, fall back to no price filter rather than applying a broken constraint. Log every extraction attempt—including the raw query, extracted values, confidence score, validation result, and latency—to enable offline eval and threshold tuning.
Model choice matters for this task. Price extraction is a structured extraction problem with clear right and wrong answers, not a creative generation task. Smaller, faster models (e.g., Claude Haiku, GPT-4o-mini, or fine-tuned open-weight models) often perform well here and reduce latency and cost compared to frontier models. If your e-commerce catalog spans multiple currencies, add a currency normalization layer after extraction that maps extracted currency codes to your canonical currency list and applies exchange rate conversion when the user's session currency differs from the catalog currency. For boundary interpretation—whether 'under $50' means < 50 or <= 50—define your house convention in the prompt's [CONSTRAINTS] section and enforce it in post-extraction validation rather than relying on the model to guess correctly every time.
Testing this prompt requires a dedicated eval harness, not manual spot checks. Build a golden dataset of at least 100 query-price pairs covering exact prices ('$29.99'), ranges ('between $20 and $50'), comparisons ('cheaper than $100', 'above $200'), currency variants ('€50', '£30-£60'), boundary cases ('free', 'under $5'), and negative examples ('best price', 'affordable', 'cheap') where no structured price filter should be extracted. Run this eval suite on every prompt change and model upgrade. Track precision (did we extract a price when we shouldn't have?) and recall (did we miss a price that was present?) separately, because the business impact of each error type differs—false positives return zero results and frustrate users, while false negatives show irrelevant products and waste browsing time.
Do not use this prompt in isolation. Price filters must be combined with other extracted constraints—category facets, brand filters, availability flags—before constructing the final search query. The price extraction service should emit its output to a filter merge layer that resolves conflicts (e.g., a price range that contradicts a category's known price floor) and applies safety limits (e.g., capping maximum range width to prevent queries that scan the entire catalog). If your system supports conversational search with follow-up turns, cache the extracted price filter in the session context and reapply it on subsequent queries unless the user explicitly changes or removes it. Finally, expose a human-override mechanism in your search UI so users can correct mis-extracted price ranges, and feed those corrections back into your eval dataset to drive continuous improvement.
Expected Output Contract
Define the exact shape, types, and validation rules for the price range filter object returned by the prompt. Use this contract to build a parser that rejects malformed outputs before they reach your search API.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
price_filter | object | Top-level object must exist. Must not be null. If no price constraint is detected, the object should contain an empty constraints array. | |
price_filter.constraints | array | Must be an array. Length 0 if no price intent is detected. Length 1 for a single range or comparison. Length 2 for a between range. | |
price_filter.constraints[].operator | enum: gte, lte, gt, lt, eq | Must be one of the listed operators. gte and lte are preferred for inclusive ranges. gt and lt are used when the query explicitly excludes the boundary. | |
price_filter.constraints[].value | number | Must be a non-negative float or integer. Null, negative numbers, or non-numeric strings must be rejected by the parser. | |
price_filter.constraints[].currency | string (ISO 4217) | If present, must be a valid 3-letter ISO 4217 currency code. If absent, the application layer should apply a default currency from session context. | |
price_filter.original_phrase | string | The exact substring from [USER_QUERY] that triggered the price extraction. Used for audit logging and debugging. Must not exceed 255 characters. | |
price_filter.confidence | number | Float between 0.0 and 1.0. Represents the model's self-assessed extraction confidence. The application layer should discard constraints with confidence below [CONFIDENCE_THRESHOLD]. | |
price_filter.normalization_notes | string | A brief human-readable note if currency conversion or unit normalization was applied. Must not contain PII or raw query data beyond the price phrase itself. |
Common Failure Modes
Price range extraction breaks in predictable ways. Here are the most frequent failure modes and how to guard against them before they reach production.
Currency Ambiguity and Symbol Collision
What to watch: The model misinterprets '$' as USD when the query context implies CAD, AUD, or another dollar currency. It also fails when multiple currencies appear in one query ('compare €500 phones to $600 phones'). Guardrail: Always pass an explicit [CURRENCY_CODE] variable into the prompt. For multi-currency queries, require the model to output per-constraint currency labels and reject ambiguous extractions.
Boundary Inclusivity Drift
What to watch: The model treats 'under $100' as max: 99.99 when the business rule requires max: 100 (exclusive). Conversely, 'up to $50' may be interpreted as inclusive when the catalog uses strict less-than filtering. Guardrail: Define an explicit [BOUNDARY_POLICY] in the prompt (e.g., 'under/over = exclusive, up to/at least = inclusive'). Add eval test cases for each boundary phrase your system supports.
Implicit Range Assumption Errors
What to watch: The model infers a lower bound of $0 for 'cheap' or an upper bound of infinity for 'premium' without explicit instruction. This produces filter clauses that either match nothing or match everything. Guardrail: Require the prompt to output null for unspecified bounds rather than guessing. If the application needs defaults, inject them in the application layer after extraction, not in the prompt.
Qualitative Price Term Misclassification
What to watch: Terms like 'affordable', 'luxury', 'budget', 'mid-range', and 'value' are mapped to hard price bands that don't match the catalog's actual price distribution. A 'budget' laptop and a 'budget' watch have different numeric ranges. Guardrail: Pass a [CATEGORY_CONTEXT] variable with category-specific price bands. If the category is unknown, the model should return the qualitative term as a separate facet rather than guessing a numeric range.
Range Reversal and Contradiction
What to watch: The model outputs min: 500, max: 100 when the user says 'between $100 and $500', or fails to detect contradictory constraints like 'under $50 and over $200'. Guardrail: Add a post-extraction validation step that checks min <= max and flags contradictory ranges. Include negative test cases in your eval set that deliberately provide reversed or conflicting price expressions.
Discount and Sale Price Confusion
What to watch: The model applies the price filter to the original price when the user means the sale price, or vice versa. 'Phones under $300 on sale' could mean original price under $300 or current sale price under $300. Guardrail: Explicitly define a [PRICE_FIELD_PREFERENCE] variable (e.g., 'apply filters to current_sale_price unless user says original/retail/list price'). When ambiguous, output both interpretations with a confidence flag and let the application layer decide or ask the user.
Evaluation Rubric
Criteria for testing the quality of generated price range filters before shipping. Each row defines a pass standard, a failure signal, and a concrete test method.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Currency Normalization | All extracted price values are normalized to the target currency specified in [CURRENCY] using the provided [EXCHANGE_RATE] context. | Output contains a raw currency symbol or value from the input without conversion to the target currency. | Unit test: Input '$50' with [CURRENCY]='EUR' and [EXCHANGE_RATE]='1.1'. Assert output value is '55.00' and currency is 'EUR'. |
Range Boundary Inclusivity | The 'gte' and 'lte' fields correctly reflect inclusive vs. exclusive language from the query ('under $100' maps to lte: 99.99, 'over $50' maps to gte: 50.01). | Boundary values are set to the exact threshold mentioned (e.g., 'under $100' produces lte: 100). | Golden dataset: Run against 20 curated queries with known boundary interpretations. Assert exact match on boundary values. |
Multi-Range AND Logic | When a query specifies a bounded range ('between $20 and $50'), the output contains a single filter object with both 'gte' and 'lte' populated. | Output generates two separate filter objects or uses an OR structure for a bounded range. | Schema check: Parse output JSON. Assert that a bounded range input produces exactly one object in the 'filters' array with both 'gte' and 'lte' keys. |
Multi-Range OR Logic | When a query specifies disjoint ranges ('under $20 or over $100'), the output contains two filter objects in an array with a top-level 'operator' field set to 'or'. | Output combines disjoint ranges into a single object or uses an 'and' operator. | Schema check: Parse output JSON. Assert 'operator' is 'or' and the 'filters' array length is 2. |
Unparseable Input Handling | When [QUERY] contains no price information, the output is an empty 'filters' array and a 'confidence' score of 0.0. | Output hallucinates a price range or returns a non-zero confidence score. | Unit test: Input 'show me red shoes'. Assert output is {'filters': [], 'confidence': 0.0}. |
Confidence Score Calibration | The 'confidence' field is a float between 0.0 and 1.0, where explicit numeric ranges score >0.9 and vague terms like 'cheap' score <0.7. | Vague terms receive a confidence score above 0.9, or explicit numbers score below 0.7. | Statistical test: Run 50 queries with labeled confidence tiers. Assert mean confidence for 'explicit' tier > 0.9 and 'vague' tier < 0.7. |
Output Schema Adherence | The output is valid JSON matching the [OUTPUT_SCHEMA] with all required fields present and no extra fields. | Output is missing required fields ('filters', 'confidence') or contains extra keys not defined in the schema. | Automated validation: Parse output with a JSON schema validator configured with [OUTPUT_SCHEMA]. Assert validation passes with no errors. |
Symbol-Only Input Handling | A query containing only a currency symbol ('$') or comparison operator ('>') without a value is treated as unparseable. | Output extracts a filter with a null or zero value. | Unit test: Input 'items under $'. Assert output is {'filters': [], 'confidence': 0.0}. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet) and minimal post-processing. Focus on getting the extraction logic right before adding validation layers. Start with a single currency and simple range formats.
codeExtract price constraints from: [QUERY] Return JSON: {"min": number|null, "max": number|null, "currency": string|null, "operator": "between"|"gte"|"lte"|"exact"|"none"}
Watch for
- Model interpreting 'affordable' or 'cheap' as concrete numbers without evidence
- Missing null handling when no price constraint exists in the query
- Currency symbol confusion ($ used for multiple currencies)
- Boundary words like 'under', 'over', 'less than' mapped to wrong operators

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us