Analytical search

Analytical search is an orchestration capability in Cortex Agents that enables analytical queries over large document collections. Traditional retrieval-augmented generation (RAG) approaches retrieve only a small number of passages, which limits their ability to answer questions requiring comprehensive analysis across hundreds or thousands of documents, including counts, aggregates, and trends. Analytical search addresses this by combining semantic search, AI functions, and SQL into one loop to answer those questions with analytical rigor over unstructured data.

How analytical search works

Analytical search enables precise analytical queries over large document sets, including filtered lists, aggregates, and temporal analysis such as:

  • “List all patients who were prescribed albuterol for asthma last year”
  • “What percentage of sales calls mentioned product X in EMEA vs. the US last year?”
  • “Identify the new themes that emerged in the notes in 2025, compared to 2024”

Analytical search operates in two layers:

Layer 1: Search to prune

Cortex Search narrows the full corpus down to a relevant candidate set by finding documents about a specific topic, isolating records containing a particular clause, or filtering to a date range. This happens without scanning every document with a large model.

Adaptive depth controls how far to search. Rather than using a fixed top-k limit, the agent dynamically adjusts the search depth based on the relevance of results: extending when the tail of results is still relevant to the question, and stopping when quality drops. This avoids two common failure modes: stopping too early and missing key documents, or going too deep and wasting compute on irrelevant ones.

Layer 2: AI functions and SQL to analyze

Once the corpus is pruned, the agent applies semantic operators directly on the result set:

  • AI_FILTER: Tests whether each document satisfies a specific semantic predicate (for example, “is this about a customer issue?”).
  • AI_EXTRACT: Pulls structured, deterministic fields out of unstructured text (for example, issue type, date, customer name).
  • AI_AGG: Summarizes and aggregates textual evidence at scale.
  • SQL: Groups, counts, joins, ranks, trends, and calculates deltas over the extracted data.

Planning and auto-routing

Before executing any analysis, the agent generates a clear execution plan and presents it for review. This lets you verify the logical steps (the scope of the search, the filters applied, and the aggregation logic) and make adjustments before any data is processed.

Auto-routing classifies query intent at runtime: simple, single-passage questions stay on the standard RAG path; corpus-wide analytical questions trigger the analytical search loop. You don’t need to specify which mode to use.

Analytical search vs. traditional RAG

The following example compares how traditional RAG and analytical search handle the query: “What were the most common customer issue types in the support cases in May 2025?”

Traditional RAG approach

With traditional RAG:

  1. The agent issues one or two broad search queries (for example, search("May 2025 customer issues")) with a small limit (typically 10 results).
  2. The agent receives approximately 10–20 search results and summarizes them directly.

Example output:

Based on the provided documents, latency and authentication are common issues,
with customers X and Y citing high query latency and customer Z mentioning
authentication errors. However, there may be more issues that were not analyzed.

This answer is imprecise and incomplete because it relies on a small subset of documents without strict date filters.

Analytical search approach

With analytical search, Cortex Agents orchestrate a multi-step workflow:

  1. Classify the query as analytical and generate an execution plan.
  2. Run structured search queries (for example, search(date="2025-05", query="issues")) with adaptive depth to capture the full relevant set of results.
  3. Apply AI_FILTER to keep only rows related to customer issues.
  4. Apply AI_EXTRACT to pull issue type and customer name from each document.
  5. Use AI_AGG and SQL to aggregate results by issue type.
  6. Return a precise, data-backed answer.

Example output:

In May 2025, quality issues (27 tickets) and latency issues (19 tickets)
were the most commonly cited customer problems. The breakdown of issue counts
by customer is as follows: ...

This result is precise because the agent works over the full relevant set of documents with date filters and SQL-style aggregation, rather than summarizing a small sample.

Analytical search triggers implicitly based on query intent. To set up the prerequisites, complete the following steps:

Note

  • If you already have a Cortex Search service, you can reuse it; you don’t need to create a new service specifically for analytical search.
  • If your agent already has a Cortex Search tool configured, you don’t need to add another one.
  1. Create a Cortex Search service:

    CREATE OR REPLACE CORTEX SEARCH SERVICE <database>.<schema>.<name>
      TEXT INDEXES CHUNK, DOC_ID [, <other_text_search_columns>]
      VECTOR INDEXES CHUNK (model = 'snowflake-arctic-embed-l-v2.0'), [, <other_vector_search_columns>]
      ATTRIBUTES [, <other_filter_columns>]
      WAREHOUSE = <warehouse_name>
      TARGET_LAG = '1 day'
    AS
    SELECT <columns>
    FROM <chunks_table>;
    
  2. Create an agent and add the Cortex Search service as a tool. For more information, see Configure and interact with Agents.

  3. Ask the agent a question with analytical intent. The agent automatically triggers analytical search when the query requires it; no additional configuration or toggle is needed.

For more information on the commands used, see CREATE CORTEX SEARCH SERVICE and CREATE AGENT.

Recommendations

Use a multi-index service and set a high result limit. Snowflake recommends using a multi-index Cortex Search service for analytical search and setting max_results to 1,000. This gives the agent enough breadth to surface the full relevant set of documents. Adaptive depth will limit the actual compute to what the question requires.

Add detailed column descriptions. The most impactful thing you can do to improve analytical search quality is to add rich descriptions to every column in columns_and_descriptions. The agent uses these descriptions to decide which columns to filter on, how to interpret values, and how to frame AI_EXTRACT and AI_FILTER calls. For each column, describe:

  • What the column contains and its expected format or value range
  • Sample values or enumerations (for example, "Values include: policy, guide, reference")
  • Whether the column is suitable for filtering, searching, or extraction
  • Any relationships to other columns

Columns without descriptions are harder for the agent to use effectively, especially for filterable attributes that determine how the search is scoped.

Use analytical search in Snowflake CoWork

When you use analytical search through Snowflake CoWork, the agent gains additional interactive capabilities:

  • Clarification questions: When the query is ambiguous, the agent asks targeted clarifying questions before starting the analysis. For example, it may ask you to confirm the time range, the scope of the corpus, or the comparison group.
  • Plan mode: The agent presents a step-by-step execution plan before running any analysis. You can review and adjust the plan, such as narrowing the date range or changing the peer set, before the agent processes any data.
  • Chart generation: The agent can automatically generate charts from analytical results.
  • Save and share artifacts: Results can be saved and shared as artifacts directly from the conversation.

Note

Analytical search does not produce PDF documents. Intermediate results used during analysis are not automatically persisted. If you want to keep the results, save or export them before ending the session.

Performance considerations

Analytical search involves both retrieval (Cortex Search queries) and compute (AI functions over result sets), so response times are longer than standard RAG. Most analytical search workflows complete in 2–6 minutes; complex analyses over large corpora may take up to 15 minutes.

You can disable analytical search for a specific agent at any time using the toggle in the agent’s tool configuration in the Agents admin page.

Cost considerations

Analytical search incurs costs associated with agent orchestration and the AI functions it uses (AI_EXTRACT, AI_FILTER, and AI_AGG). Adaptive depth limits unnecessary AI function calls by stopping the search when results are no longer relevant. For more information on AI function costs, see Snowflake Cortex AI functions incur compute cost based on the number of tokens….