Skip to main content
Prompts Azure AI Search Query Extractor

model data_extraction system risk: low

Azure AI Search Query Extractor

The prompt instructs the model to act as a JSON Query Extractor that parses Azure AI Search request JSON to extract filter and search parameters, then formats them as a list of obj…

PROMPT

---
name: extract-query-conditions
description: A skill to extract and transform filter and search parameters from Azure AI Search request JSON into a structured list format.
---

# Extract Query Conditions

Act as a JSON Query Extractor. You are an expert in parsing and transforming JSON data structures. Your task is to extract the filter and search parameters from a user's Azure AI Search request JSON and convert them into a list of objects with the format [{name: parameter, value: parameterValue}].

You will:
- Parse the input JSON to locate filter and search components.
- Extract relevant parameters and their values.
- Format the output as a list of dictionaries with 'name' and 'value' keys.

Rules:
- Ensure all extracted parameters are accurately represented.
- Maintain the integrity of the original data structure while transforming it.

Example:
Input JSON:
{
  "filter": "category eq 'books' and price lt 10",
  "search": "adventure"
}

Output:
[
  {"name": "category", "value": "books"},
  {"name": "price", "value": "lt 10"},
  {"name": "search", "value": "adventure"}
]

REQUIRED CONTEXT

  • Azure AI Search request JSON

ROLES & RULES

Role assignments

  • Act as a JSON Query Extractor.
  • You are an expert in parsing and transforming JSON data structures.
  1. Ensure all extracted parameters are accurately represented.
  2. Maintain the integrity of the original data structure while transforming it.

EXPECTED OUTPUT

Format
json
Schema
json_array · name, value
Constraints
  • JSON array of objects
  • each object has 'name' and 'value' keys

SUCCESS CRITERIA

  • Parse input JSON to locate filter and search components.
  • Extract relevant parameters and their values.
  • Format output as list of objects with 'name' and 'value' keys.

FAILURE MODES

  • Misparsing complex filter strings.
  • Incorrectly transforming parameters.
  • Output not in specified list format.

EXAMPLES

Includes one input JSON example with filter and search parameters and its corresponding output list.

CAVEATS

Dependencies
  • User's Azure AI Search request JSON.
Missing context
  • Full Azure AI Search request JSON schema.
  • Handling of absent filter/search fields.
  • Edge cases like empty strings, arrays, or non-string filters.
Ambiguities
  • Parsing rules for complex OData filter expressions (e.g., parentheses, functions, or/or) not fully specified beyond simple example.
  • Unclear which 'relevant parameters' beyond filter and search; e.g., does it include searchFields, facets?

QUALITY

OVERALL
0.85
CLARITY
0.90
SPECIFICITY
0.85
REUSABILITY
0.90
COMPLETENESS
0.80

IMPROVEMENT SUGGESTIONS

  • Add explicit parsing rules for OData filters: split on 'and'/'or', extract field before operator, value after, preserve operators in value.
  • Provide additional examples for complex filters (e.g., '(category eq 'books' or genre eq 'sci-fi') and price lt 10').
  • Specify exact fields to extract (only 'filter' and 'search') and ignore others.
  • Instruct on output for missing fields: e.g., skip or include with null value.

USAGE

Copy the prompt above and paste it into your AI of choice — Claude, ChatGPT, Gemini, or anywhere else you're working. Replace any placeholder sections with your own context, then ask for the output.

MORE FOR MODEL