RAG prompt: rewrite a chat question into search queries
# RAG prompt: rewrite a chat question into search queries code: 1otu676 | type: prompt | language: en | licence: MIT | version: v1 description: Turns the last message of a conversation into a standalone search query plus three variants, before retrieval. page: https://contextetech.com/en/prompts/rag-query-rewriting-1otu676 mcp: connect https://contextetech.com/mcp then call load_resource with code "1otu676" (or ask "load 1otu676") json: https://contextetech.com/api/resources/contextetech--rag-query-rewriting python: pip install contexte && contexte get 1otu676 citation (required by the licence): contextetech. (2026). RAG prompt: rewrite a chat question into search queries (Version 1) [Prompt]. Contexte Tech. https://contextetech.com/en/prompts/rag-query-rewriting-1otu676
Turns the last message of a conversation into a standalone search query plus three variants, before retrieval.
Template
You prepare search queries for a document retrieval system. You do not answer the question.
Conversation so far:
{{conversation}}
Last user message: {{question}}
Return JSON only:
{"standalone": "...", "variants": ["...", "...", "..."], "language": "..."}
- "standalone": the last message rewritten so it makes sense without the conversation (resolve "it", "that one", dates like "last year").
- "variants": three different phrasings: one with synonyms, one shorter with key terms only, one in the language of the documents if it differs.
- "language": the language code of the standalone query.
Context: the queries feed a search engine over company documents, so they must be precise.
Most important: keep every name, number and date from the conversation; do not invent terms that are not in it.
First, find what the last message refers to; then write the standalone query; finally, check that it makes sense on its own.
If information is missing to resolve a reference, keep the original words.
Each query: 12 words maximum, neutral tone, in English unless the documents use another language. Cite the sources of names only if they appear in the conversation.
Example: "And for 2024?" after a question on revenue becomes "company revenue 2024".Variables
Notes
Run the retrieval with each query and merge the results before answering. Works with keyword, vector or hybrid search.
- Identifier
- contextetech--rag-query-rewriting
- File
- rag-query-rewriting.json
- Format
- JSON (application/json)
- Size
- 1,631 bytes (1.6 KB)
- Encoding
- UTF-8
- Estimated tokens
- ≈ 453
- Commercial use
- Allowed
- Personal data
- None
- Version
- 1.0
- Published on
- October 18, 2026 at 8:00 AM
- Updated on
- October 18, 2026 at 8:00 AM
- Storage
- in database
Statistics
Likes : 0 · Comments : 0
Click a counter to show or hide it, hover the chart for details. One view per visitor per day, bots excluded; counting started on 30 September 2026.
Estimated cost
- Input tokens per call
- ≈ 491
| Model | Per call | Per month |
|---|---|---|
| GPT-6 Luna · OpenAIbest price | €0.00004 | €0.04 |
| DeepSeek Flash · DeepSeek | €0.00013 | €0.13 |
| Mistral Large · Mistral AI | €0.00022 | €0.22 |
| DeepSeek V4 Pro · DeepSeek | €0.00057 | €0.57 |
| GPT-6 Sol · OpenAI | €0.00087 | €0.87 |
| Claude Sonnet 5.5 · Anthropic | €0.00087 | €0.87 |
| Claude Opus 5.5 · Anthropic | €0.00173 | €1.73 |
| Self-hosted open-source model (Ollama, vLLM) | €0 in API fees (server cost only) | |
Input cost only, excluding the model's answer. Providers' public standard prices (Mistral AI, DeepSeek, OpenAI, Anthropic) converted from USD to euros at the ECB rate of October 13, 2026. Estimate: 1 token ≈ 3.6 characters.
Common to all 3 regions
Created by the author, no outside source.
Commercial use allowed · credit the author · changes allowed.
Text or data only: no access to files, network or commands.
Hosted in France (Scaleway, Paris). No transfer outside the EU.
European Union · 5/5
No personal data.
No training data: no summary required.
United States · 5/5
No personal data.
No training data: no documentation to publish.
China · 5/5
No personal data.
No training data; AI-generated content published in China must be labelled (2025).
Indicative summary as of 30/09/2026, not a legal certification. Method and sources →
Prompt relevance
The detailed criteria are for members.
Every criterion, the points removed and a tip to fix each one.
The detailed criteria are for members.
Every criterion, the points removed and a tip to fix each one.
Checks
MCP contexte
https://contextetech.com/mcp
load 1otu676
Add the URL as a connector in your AI apps' settings, then send the request above.
Python contexte
import contexte p = contexte.load("contextetech/rag-query-rewriting") print(p.fill(conversation="…", question="…"))
API
import json, urllib.request url = "https://contextetech.com/api/resources/contextetech--rag-query-rewriting" fiche = json.load(urllib.request.urlopen(url)) print(fiche["title"] or fiche["name"])
rag-query-rewriting.json
{
"format": "contextec/prompt/v1",
"id": "contextetech/rag-query-rewriting",
"description": "Turns the last message of a conversation into a standalone search query plus three variants, before retrieval.",
"license": "MIT",
"language": "en",
"template": "You prepare search queries for a document retrieval system. You do not answer the question.\n\nConversation so far:\n{{conversation}}\n\nLast user message: {{question}}\n\nReturn JSON only:\n{\"standalone\": \"...\", \"variants\": [\"...\", \"...\", \"...\"], \"language\": \"...\"}\n\n- \"standalone\": the last message rewritten so it makes sense without the conversation (resolve \"it\", \"that one\", dates like \"last year\").\n- \"variants\": three different phrasings: one with synonyms, one shorter with key terms only, one in the language of the documents if it differs.\n- \"language\": the language code of the standalone query.\n\nContext: the queries feed a search engine over company documents, so they must be precise.\nMost important: keep every name, number and date from the conversation; do not invent terms that are not in it.\nFirst, find what the last message refers to; then write the standalone query; finally, check that it makes sense on its own.\nIf information is missing to resolve a reference, keep the original words.\nEach query: 12 words maximum, neutral tone, in English unless the documents use another language. Cite the sources of names only if they appear in the conversation.\nExample: \"And for 2024?\" after a question on revenue becomes \"company revenue 2024\".",
"variables": [
"conversation",
"question"
]
}
Community
No comments yet. Share your feedback, it will help the next person.