AI-assisted analytical search
The AI search API helps an agent turn a business term into a permitted analytical resource or table column. It returns enough context to choose the next exploration step without first loading every document, while usage signals help the agent prefer resources that the organisation uses.
Search API role
The API is a discovery layer for agent-assisted exploration. It does not answer the business question or build the final query. Instead, it exposes the site's own names and definitions so an agent can connect business language to the analytical assets used by data exploration and query building. It complements resource discovery and list filtering by serving agent-led searches for analytical meaning.
The API exposes two search actions:
| Action | Discovery target | Main use |
|---|---|---|
search_content | Workbooks, queries, charts, and dashboards | Find named resources and definitions that relate to a business term |
search_columns | Stored table-column metadata | Find fields that can become query inputs |
Both actions are available to an Insights User through the normal Insights API access boundary. The caller must still use the query-building and execution flows in query editor and execution workflow and the server-side support in query utilities to inspect or run analysis.
Resource discovery
The search API covers the vocabulary that links an organisation's business terms to its analytical work. Content search looks at workbook titles, query titles and operations, chart titles and configuration, and dashboard titles and items; column search looks at stored names and types for readable tables.
The API uses the matching resource as the unit of discovery. A result identifies the resource and its workbook context when one exists. This lets an agent move from a broad term to a specific analytical object before it asks for more detail.
References: insights/…/search.py• L25-40 insights/…/search.py• L43-83
Content search contract
search_content(term, limit=20) finds permitted workbooks, queries, charts, and dashboards whose searchable content contains the term. A blank or whitespace-only term returns no results, so an agent should only call this action after it has a usable business term.
Each result has this shape:
| Field | Meaning |
|---|---|
doctype | The analytical resource type |
name | The resource identifier |
title | The resource's display title |
workbook | The containing workbook identifier, or the resource itself for a workbook result |
workbook_title | The containing workbook title when it can be resolved |
matched_field | The field in which the term matched |
snippet | A short context excerpt with the matched text marked in Markdown-style bold |
used_by_charts | Number of readable charts that use the result |
used_by_dashboards | Number of readable dashboards that use the result, directly or through charts |
dashboard_views | Readable dashboard opens in the last 30 days for the result's downstream reach |
The default response contains at most 20 results. The caller can pass limit when it needs a smaller or larger candidate set. The API ranks title matches before matches in other searchable fields, then favors recent dashboard reach, dashboard use, and chart use. Recency breaks ties. These signals help an agent select a trusted definition, but they do not prove that a result answers the question.
References: insights/…/search.py• L43-72 insights/…/search.py• L112-143 insights/…/search.py• L309-315
Column search contract
search_columns(term, data_source=None, limit=100) finds readable table columns whose stored names contain the term. It is intended to turn a business word such as revenue into a field candidate that a later query workflow can use.
Each result has this shape:
| Field | Meaning |
|---|---|
data_source | The source that owns the table |
table_name | The table identifier |
label | The table's user-facing label |
column | The matching column name |
type | The stored column type |
The default response contains at most 100 matches. data_source narrows the search to one source when the agent already knows where to look. Exact column names rank before other substring matches. A table appears only when its column metadata has been stored and the caller may read that table.
References: insights/…/search.py• L75-109 insights/…/insights_table_v3.py• L234-264
Access and ranking
The API treats permissions as part of the search contract rather than as a later filter. Search results, workbook context, and usage counts are based only on resources that the caller may read. This prevents an agent from learning the name or popularity of a resource that it cannot open.
Content matching is literal substring matching within the defined searchable fields. The API protects user-entered wildcard characters from changing that meaning. Search is therefore useful for vocabulary discovery, but it is not semantic search and does not infer synonyms.
Usage measures downstream reach. Query use flows through its readable charts and dashboards. Chart use flows through readable dashboards. Dashboard use is measured by its own opens in the last 30 days. A high count indicates organisational use, not correctness for the current question.
References: insights/…/search.py• L4-13 insights/…/search.py• L189-191 insights/…/search.py• L212-263 insights/decorators.py• L118-144 insights/…/dashboards.py• L113-131
Agent exploration flow
An agent should use the API to narrow the site's vocabulary before it selects a query path. The flow separates discovery from execution: content results provide analytical context, column results provide field candidates, and the linked query tools perform the next operation.
The following flow shows the contract between discovery and later analytical work.
flowchart LR
Q[Business question] --> T[Search term]
T --> C[search_content]
T --> F[search_columns]
C --> R[Resource candidates]
F --> K[Column candidates]
R --> D[Inspect permitted analytical resource]
K --> D
D --> B[Build or refine query]
B --> X[Execute and present results]
The agent should use search_content when it needs an existing definition, query, chart, or dashboard. It should use search_columns when it needs a field or table that can support a new query. After discovery, it should follow the query editor and execution workflow or query utilities rather than treating search results as executable queries.
References: insights/…/search.py• L43-109
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the content result fields aligned with the agent's resource-selection contract, especially
matched_field,snippet, workbook context, and usage counts. - Keep the searchable resource fields aligned with the names and structures that users see in workbooks, queries, charts, and dashboards.
- Keep permission filtering consistent across direct results and downstream usage counts. A readable child must not expose an unreadable parent through its counts or names.
- Keep the column result fields aligned with stored table metadata and with the query-building consumers that use
data_source,table_name,column, andtype. - Recheck the meaning of the ranking window if dashboard view tracking or the 30-day period changes.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The agent sends an empty term | The API returns no candidates | Validate the term before search and ask for a more specific business word |
| A term exists only in a synonym or in an unsearched field | Content search returns no resource | Search the organisation's recorded terms, then use column search or another known resource path |
| Table column metadata was not stored or is stale | A valid table or field is absent from column results | Treat column search as metadata discovery and confirm the selected source before building the query |
| The caller cannot read a resource or its parent dashboard | The resource or related usage signal is absent | Continue only with returned resources and do not infer hidden names |
| The agent treats usage as semantic relevance | A popular resource can be chosen for the wrong question | Use snippets and titles to verify meaning before query construction |
| A result is treated as an executable query | Discovery output is used without the required query flow | Pass the selected resource or column into the query editor or query utilities |
Key files
| File | Why to read it |
|---|---|
| insights/…/search.py | Defines the search actions, result contracts, matching scope, access behavior, snippets, and ranking signals. |
| insights/…/insights_table_v3.py | Defines the stored-column view that supports column discovery and its permission boundary. |
| insights/…/dashboards.py | Defines the dashboard view counts used as the recent usage signal. |
| insights/decorators.py | Defines the standard Insights User API access boundary applied to the search actions. |
| docs/query-editor-and-execution.md | Related page for the workflow that consumes discovered resources and fields. |
| docs/query-utilities.md | Related page for the server-side query support that follows discovery. |