Metadata Filter Builder For Vector Stores
Translates a natural-language query into structured metadata filters plus a semantic search string.
Prompt
ROLE: You are a query compiler that converts natural language into vector-store filter expressions.
CONTEXT:
User query: [QUERY]
Available metadata fields with types and allowed values: [SCHEMA]
Filter syntax of the target store (e.g., Pinecone, Weaviate, pgvector): [SYNTAX]
TASK:
1. Separate the query into a SEMANTIC part (matched by embedding similarity) and STRUCTURED constraints (matched by metadata filters: dates, categories, authors, status, numeric ranges).
2. Map each structured constraint to a valid field, operator, and value from the schema.
3. Emit the metadata filter in the target store's syntax.
4. Emit the cleaned semantic search string with the structured parts removed.
OUTPUT FORMAT (JSON):
{
"semantic_query": "...",
"metadata_filter": { ... in target syntax ... },
"unmapped_constraints": ["any constraint with no matching field"],
"assumptions": ["any value normalization you applied"]
}
CONSTRAINTS:
- Only reference fields and values that exist in the schema.
- Never push a vague concept into a metadata filter; keep ambiguous intent in the semantic query.
- Normalize dates and enums to the schema's expected format and record it under assumptions.How to use this prompt
- 1
Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.
- 2
Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.
- 3
Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.
Techniques in this prompt
Pins the response to a defined structure so it drops straight into your workflow.
Learn this techniqueForces explicit intermediate reasoning instead of jumping to a conclusion, which improves accuracy on hard tasks.
Learn this techniqueRelies on one clear instruction with no examples — fast, and effective when the task is unambiguous.
Learn this techniqueRecommended models
Build on this prompt
Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.
More in RAG & Knowledge Retrieval
Grounded Answer With Inline Citations
Answers a user question strictly from retrieved passages, attaching an inline citation to every factual claim.
Faithfulness Auditor For RAG Outputs
Audits a generated answer against its source passages and flags every unsupported or contradicted claim.
Query Decomposition For Multi-Hop Retrieval
Breaks a complex question into ordered atomic sub-queries optimized for a vector search retriever.
Hybrid Search Reranker With Justification
Reranks candidate passages by true relevance to the query and explains each ranking decision.