Learn  /  Guides

Search your tables by meaning in BigQuery: AI.SEARCH, AI.RANK and the new AI indexes explained

Finding "the reviews that complain about delivery" used to need an embedding pipeline, a vector index and a fair amount of Python. In BigQuery it is now a few lines of SQL. Here is how the three new pieces fit together.

Guide8 min readUpdated 23 November 2026
SQLAIDatabases
All guides and cheat sheets

Keyword search finds rows that contain a word. Semantic search finds rows that mean the same thing, even when the words differ: "late parcel" matches "my order took two weeks". In November Google added three pieces to BigQuery that make this practical from SQL: a rerank option for AI.SEARCH and the new AI.RANK function (both generally available on 17 November), and AI indexes (preview, 19 November), which build and maintain the embeddings for you.

Your question"a gift for a child who loves board games"
AI.SEARCHfinds the 50 closest rows by meaning
AI.RANK or rerankscores them 0 to 1 against the question
Top resultsthe five rows that really answer it

1. AI.SEARCH: find rows by meaning

AI.SEARCH needs a table that already has embeddings, either through an AI index or through an automatically generated embedding column. This example from Google's documentation creates a product table whose embedding column fills itself whenever rows are inserted:

SQL
CREATE TABLE mydataset.products (
  name STRING,
  description STRING,
  description_embedding STRUCT<result ARRAY<FLOAT64>, status STRING>
    GENERATED ALWAYS AS (AI.EMBED(
      description,
      connection_id => 'us.example_connection',
      endpoint => 'text-embedding-005'
    ))
    STORED OPTIONS( asynchronous = TRUE )
);

INSERT INTO mydataset.products (name, description) VALUES
  ("Lounger chair", "A comfortable chair for relaxing in."),
  ("Super slingers", "An exciting board game for the family."),
  ("Encyclopedia set", "A collection of informational books.");

SELECT base.name, base.description, distance
FROM AI.SEARCH(TABLE mydataset.products, 'description', "A really fun toy");

The board game comes first, although the word "toy" appears nowhere. Each result has a base struct with the table's columns and a distance: lower means closer.

AI.SEARCH arguments worth knowing

Base table or query
TABLE mydataset.products, or a query to pre-filter it. Only SELECT, FROM and WHERE are allowed in that query.
mode
'VECTOR', 'HYBRID' (vector plus keyword) or 'AUTO', the default.
top_k
How many rows to return. The default is 10.
distance_type
'EUCLIDEAN' (default), 'COSINE' or 'DOT_PRODUCT'.
rerank
TRUE adds a rerank_score from 0 to 1 and reorders the candidates.

2. AI.RANK: sort any rows by relevance

AI.RANK does not need embeddings at all. You give it rows, a text column and a question, and it returns each row with a rank (1 is best) and a score between 0 and 1. It runs on a public dataset, so you can try it now:

SQL
SELECT rank, score, title
FROM AI.RANK(
  TABLE `bigquery-public-data.bbc_news.fulltext`,
  'title',
  'downward trends in the housing market',
  top_n => 5
);

Ranking costs money for every row it scores, so narrow the rows first. Here only business stories are ranked, on the full article text:

SQL
SELECT rank, score, title
FROM AI.RANK(
  (
    SELECT title, body
    FROM `bigquery-public-data.bbc_news.fulltext`
    WHERE category = 'business'
  ),
  'body',
  'executives who resigned after an accounting scandal',
  top_n => 3
);

AI.SEARCH

Retrieve
  • Fast over large tables, using embeddings and indexes
  • Returns the closest candidates by distance
  • Distance is not a relevance score you can explain to users

Use it to go from millions of rows to tens.

AI.RANK

Rerank
  • A clear 0 to 1 relevance score per row
  • Works on any rows, no embeddings needed
  • Billed per row ranked, so keep the input small

Use it to go from tens of rows to the right five.

You can also do both in one call: AI.SEARCH(..., top_k => 5, rerank => TRUE) retrieves candidates (by default five times top_k) and reranks them. Reranking needs the Discovery Engine API enabled and the discoveryengine.rankingConfigs.rank permission, which the Discovery Engine Viewer role includes.

3. AI indexes: no embedding pipeline at all (preview)

An AI index is BigQuery's managed shortcut: you name the text columns, and BigQuery creates and maintains the embeddings in the background.

SQL
CREATE AI INDEX products_ai_index
ON mydataset.products(name, description);

-- or let BigQuery pick up to 50 text columns
CREATE AI INDEX products_ai_index
ON mydataset.products(AUTO COLUMNS);

Indexing runs in the background. Check INFORMATION_SCHEMA.AI_INDEXES for the state, the coverage percentage and the number of rows not yet indexed, because AI.SEARCH only searches rows that have been processed. When a table has an AI index, you do not need to name the column to search.

Preview limits to know

One index per table
Up to 50 top-level, non-repeated STRING columns. To change the columns, drop and recreate the index.
Standard tables only
Not views, external or BigLake tables, Iceberg tables or snapshots.
Row limits at creation
1 million rows on on-demand pricing, or 100 million with a BACKGROUND reservation.
AUTO COLUMNS
Picks columns once, at creation; it may include IDs or URLs, so a named list is usually better.
Not for exact matches
IDs, codes and numbers belong in WHERE clauses, not in the search phrase.

What it costs

  • Search (vector and hybrid) uses normal BigQuery compute.
  • Embeddings for indexed rows and for search phrases follow the price of the embedding model used.
  • AI index: creating and dropping is free; background indexing is billed like DML, or uses slots if you assign a BACKGROUND reservation; index storage is billed as storage.
  • Reranking (AI.RANK or rerank => TRUE) is billed through the ranking API for every row ranked.

When to use it

  1. 1

    Support and feedback

    Find all tickets or reviews about the same problem, whatever words customers used.

  2. 2

    Product catalogues

    Let analysts search descriptions in plain language to build segments.

  3. 3

    Before an LLM call

    Retrieve the five most relevant documents, then pass only those to an AI function.

  4. 4

    Deduplication

    Find near-duplicate records that exact matching misses.

Check your understanding

1/3What does AI.RANK return for each row?

2/3Why filter rows before calling AI.RANK?

3/3What is the status of AI indexes in BigQuery?

More: embeddings and vector search for analysts, the BigQuery November update and the SQL cheat sheet.

Sources: BigQuery release notes (16 to 19 November 2026), Google Cloud documentation for AI.SEARCH and AI.RANK (examples quoted from it), and a detailed walkthrough of CREATE AI INDEX by TechInnovateIT. Preview features can change before general availability.

Alessandro Ecclesie AgazziWritten by Alessandro Ecclesie Agazzi, analytics engineer in London. Updated 23 November 2026. About me

Found this useful?

New guides and "what's new" explainers on data and AI land here regularly. Follow along on LinkedIn, or share this one with a colleague.