CertSafari
    Databricks Certified Context Engineer Associate· Lessons

    Domain 4 · Lesson 28/45

    Query Understanding Techniques: Rewriting, Filter Extraction, Intent Classification

    Given a Databricks agent pipeline that produces accurate but contextually mismatched responses, identify the pipeline stage where user intent should be resolved before context retrieval.

    9 min read
    2.25% of exam
    2 sources
    Published 3 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Explain how query rewriting and filter extraction turn a user query into a retrieval query that captures intent
    • State the downstream changes each technique needs before it works
    • Design a multi-step query understanding component (intent classification, entity extraction, rewriting) and weigh its latency cost
    • Know when to have the agent ask a clarification question instead of guessing intent

    1.Query rewriting: restating what the user meant

    In a Databricks RAG chain, user intent is resolved in query understanding, the step at the start of the chain that turns the raw user query into the retrieval query. Retrieval sees nothing except that query. This page covers the techniques that go into this step.

    The first is query rewriting: "Query rewriting involves translating a user query into one or more queries that better represent the original intent." Its stated purpose is to make it more likely that retrieval finds the most relevant documents. It helps most with complex or ambiguous queries, or with queries whose wording doesn't match the terminology in the documents. Databricks gives three examples:

    - Paraphrasing conversation history in a multi-turn chat. A follow-up like "what about the other one?" is meaningless to a vector search on its own. The rewrite folds in the earlier turns so the retrieval query stands alone. - Correcting spelling mistakes in the user's query. - Replacing words or phrases with synonyms to capture a broader range of relevant documents.

    A rewrite can also produce several queries from one request, which suits a question that really asks two things.

    Databricks attaches a constraint to rewriting that's easy to overlook: "Query rewriting must be done in conjunction with changes to the retrieval component". A rewrite is only useful if the retriever is set up to make use of it. If the rewritten query is written in terminology or a form that the index and retrieval strategy don't handle well, rewriting can just move the mismatch to a different place. Treat query understanding and retrieval as one unit that you tune together.

    Checkpoint 1 of 5· Exam question

    In a multi-turn support chat, a user first asks about their laptop warranty, then asks 'What about the other one?' The agent retrieves accurate warranty terms, but for the wrong device because it did not identify which device 'the other one' refers to. What change to the pipeline best prevents this failure?

    Checkpoint 2 of 5· Check yourself

    In a multi-turn support chat, follow-up questions retrieve generic documents while first-turn questions work well. Which query understanding technique addresses this most directly?

    Sources1

    2.Filter extraction: turning stated criteria into retrieval parameters

    Some intent is better expressed as constraints than as reworded text. If a user asks for "reports from 2023" or about a specific product, a semantic search over the whole corpus may return content that's similar but from the wrong year or for the wrong product. That's the accurate-but-mismatched pattern again. Filter extraction handles this. It "involves identifying and extracting these filters from the query and passing them to the retrieval step as additional parameters." Databricks' examples are time periods ("articles from the last 6 months"), products, services or categories ("laptops"), and geographic entities such as city names or country codes.

    Filter extraction has more dependencies than rewriting. It requires changes to both the metadata extraction data pipeline and the retriever chain. The metadata step has to make sure the relevant fields exist on every document or chunk, and "the retrieval step should be implemented to accept and apply extracted filters." Extracting "2023" from the query is pointless if no chunk has a year field, or if the retriever ignores the parameter.

    Query rewriting compared with filter extraction
    AspectQuery rewritingFilter extraction
    What it producesOne or more reformulated retrieval queriesFilter parameters passed to the retrieval step
    Typical examplesParaphrasing multi-turn history, fixing spelling, adding synonymsTime periods, products or categories, geographic entities
    Problem it fixesAmbiguous queries, or wording that doesn't match document terminologyResults drawn from the wrong subset of the data
    Other components that must changeThe retrieval componentThe metadata extraction data pipeline and the retriever chain

    Checkpoint 3 of 5· Match them up

    Match each query understanding output to the user request it best fits

    Tap a term, then the definition that fits it.

    Sources1

    3.Multi-step intent resolution and clarification

    Another design decision is whether query understanding should be one LLM call or several. A single, carefully written prompt is efficient. Databricks notes that splitting complex logic across several calls often gives better results, and calls this a general rule of thumb whenever many complex steps would otherwise go into one prompt. For example, "you might use one LLM call to classify the query intent, another to extract relevant entities, and a third to rewrite the query". The tradeoff is stated directly: "Although this approach may add some latency to the overall process, it can allow for more fine-grained control". It can also improve the quality of what gets retrieved.

    For a customer support bot, the multi-step component looks like this:

    1. Intent classification. An LLM assigns the query to predefined categories such as product information, troubleshooting or account management. 2. Entity extraction. "Based on the identified intent, use another LLM call to extract relevant entities from the query", for example product names, reported errors or account numbers. 3. Query rewriting. "Use the extracted intent and entities to rewrite the original query into a more specific and targeted format", for example a query that names the deployment target and the exact error.

    Checkpoint 4 of 5· Put it in order

    Order the steps of the multi-step query understanding component Databricks describes for a customer support bot

    1. 1.Classify the query into a predefined intent category
    2. 2.Extract entities relevant to that intent, such as product names or error messages
    3. 3.Pass the rewritten query to retrieval
    4. 4.Rewrite the query into a specific, targeted retrieval query using the intent and entities

    Sometimes intent can't be inferred because the user simply hasn't given the key detail. Databricks' Genie Agent guidance handles this with an explicit clarification rule. For example, when a user asks for a sales breakdown without a time range, sales channel or KPIs, the agent "must ask a clarification question first to gather necessary information." The instruction should name the trigger condition, the missing details, the required action, and an example question to ask. It's still intent resolution that happens before retrieval and answering. The difference is that the agent gets the missing piece from the user instead of guessing.

    Checkpoint 5 of 5· Exam question

    A common agent pipeline pattern proceeds through the stages: reason and plan, find information, reason again, then act and respond. At which stage should the agent establish what the user is actually asking for?

    Sources12

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.Adding a query rewriting step by itself is enough to fix mismatched retrieval.Why is that wrong?

      Databricks says rewriting must be paired with changes to the retrieval component. A rewrite the retriever isn't set up to use can just move the mismatch elsewhere.

      Covered in Query rewriting: restating what the user meant

    2. 2.Filter extraction only needs a change to the query understanding prompt.Why is that wrong?

      The data pipeline also has to provide the matching metadata fields on each chunk, and the retriever has to accept and apply the filters.

      Covered in Filter extraction: turning stated criteria into retrieval parameters

    3. 3.A single LLM call is always the better design for query understanding because it adds no latency.Why is that wrong?

      Separate calls for intent classification, entity extraction and rewriting add latency but give finer control and can improve what gets retrieved. It's a tradeoff to weigh, not a fixed rule.

      Covered in Multi-step intent resolution and clarification

    Sources

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Query rewriting involves translating a user query into one or more queries that better represent the original intent.”
      ↩︎ Query rewriting: restating what the user meant
      “Query rewriting must be done in conjunction with changes to the retrieval component”
      ↩︎ Query rewriting: restating what the user meant
      “the retrieval step should be implemented to accept and apply extracted filters”
      ↩︎ Filter extraction: turning stated criteria into retrieval parameters
      “Extracting specific time periods mentioned in the query”
      ↩︎ Filter extraction: turning stated criteria into retrieval parameters
      “you might use one LLM call to classify the query intent, another to extract relevant entities, and a third to rewrite the query”
      ↩︎ Multi-step intent resolution and clarification
      “Based on the identified intent, use another LLM call to extract relevant entities from the query”
      ↩︎ Multi-step intent resolution and clarification
      “Query rewriting must be done in conjunction with changes to the retrieval component”
      ↩︎ Exam trap 1
      “The metadata extraction step should ensure that the relevant metadata fields are available for each document/chunk”
      ↩︎ Exam trap 2
      “Although this approach may add some latency to the overall process, it can allow for more fine-grained control”
      ↩︎ Exam trap 3
      “Paraphrasing conversation history in a multi-turn chat”
      ↩︎ Checkpoint
      “Filter extraction involves identifying and extracting these filters from the query and passing them to the retrieval step as additional parameters.”
      ↩︎ Checkpoint
      “Use the extracted intent and entities to rewrite the original query into a more specific and targeted format”
      ↩︎ Checkpoint
    2. 2.
      “you must ask a clarification question first to gather necessary information”
      ↩︎ Multi-step intent resolution and clarification

    Ready to test yourself?

    Practise Databricks Certified Context Engineer Associate in quiz mode.

    Spotted a mistake, or was something unclear? Tell us.