search_everything finds records in the Provider Pool by what their text
says: calls where a customer raised pricing, issues about an SSO login loop.
search_available_data
finds where data lives, the tables and columns. Use that first when you
do not yet know the table. Use search_everything when the question is about
the contents of records.
It searches only the Provider Pool, and only text fields a Provider has
flagged for this search. It returns one row per matching source record, never
one per passage. A record a Provider Policy hides from you is left out, and
its text never appears in a snippet. A session that cannot query the Provider
Pool does not see its records here.
An empty result is not proof that nothing matches. A missing model policy, a
policy that admits no embedding model for this search, or an index that is
missing or still building all return no rows, the same as a search that found
nothing. An index built before the record time existed applies a
time window only after the search, until its next build. Try the question again later, or use search_available_data and
read the table directly.
Each matching record is read again from its source table before it is
returned. When one source table takes too long to read, its records are left
out of that search, and records from the other tables still return. When no
source table can be read in time, the search fails with
DEADLINE_EXCEEDED and the error code QL-TO-004
(ROW_SEARCH_REREAD_TIMEOUT). The message names the time limit. Run the
search again. If it fails again, narrow the scope to fewer tables, such as
one Provider. Preview a Plot answers it as HTTP 504 with the same code and
message:
search_everything returns no rows. See Turn off
search of Provider records by meaning.
The function runs only in interactive queries, such as Preview a Plot or a
Plot that a browser Pane runs. A Plot that a Report runs cannot call it:
saving one records the error PV_STMT_003, and the Plot cannot publish until
the call is removed. For a Report, search first, then write the Plot’s SQL
against the source table.
Arguments
The function takes up to four arguments, by position only:search_everything(query [, scope [, limit [, half_life]]]). Named
arguments (query => ...) are refused.
A scope such as
providers.jiracloud.* keeps the search to one Provider.
providers.jiracloud.issues.body keeps it to one field. The Workspace Pool
is not searched. A scope that starts with workspace is refused.
Each argument is a literal or a bound parameter, such as $1. A Plot that a
Pane runs can search for the text a person types in the Pane. The Pane sends
that text as the parameter’s value:
CAST($1 AS VARCHAR), also works. Saving or preparing the Plot plans the
call without a value. A search that runs with no value for one of its
parameters is refused with QL-PL-018 and does not search.
Arguments the function cannot search are refused before anything runs: a
scope outside the Provider Pool, a limit outside 1 to 100 or not a whole
number, an empty query, a query or scope that is not text, a half-life that is
not a positive INTERVAL, or a parameter with no value. The refusal is INVALID_ARGUMENT with the error code QL-PL-018, as in
search_available_data,
and its message names the argument and what to use instead. Preview a Plot
answers it as HTTP 400 with the same code and message:
Results
Each row is one source record, best passage first.score is that passage’s
similarity, from 0 to 1. It is not a sum across passages, so a long record
does not outrank a short one that matches more closely. matched_chunks is
how many of the record’s passages were among the candidates and still match
the text stored for them.
A passage matches when the record, read now, still yields the same passage.
Some fields are searched with context from the same record, such as an
issue’s title before its body, a call transcript is searched as windows
of speaker turns, and a Notion page is searched as its blocks under its
title. A title with fewer than two telling words is not searched, such as a
Drive file called “Test.pdf”. Other text with fewer than four words is not
searched. A record whose field, context or turns changed after
it was indexed is left out until the index catches up.
The snippet is the beginning of the best passage, not the whole record.
span
names the rest. Read the full record from the source table.
updated_at is the time of the record’s last change, read from the source
table each time the record is read again. It is not the time the matched
passage changed: an issue with an old description and a new status is fresh.
A table’s record time is its field that the Provider marks as the record’s
last change, else its one event time. A list searched under its parent, such
as a Notion page’s blocks, takes the parent’s time. A record with no time of
its own that is keyed by another record takes that record’s time: a Gong
call transcript takes the start time of its call. A call you may not read
gives its transcript no time.
Time window
Boundupdated_at with plain SQL in the WHERE clause. The search applies
the bound inside the search itself, not only to the records it already
chose. So a narrow window still returns up to limit records when matching
records exist, even when the closest passages are older.
AND:
updated_atcompared with a time:=,<,<=,>or>=. The time can be a literal, a date, or an expression of constants such asnow() - INTERVAL '30 days'orCURRENT_DATE - INTERVAL '7 days'.updated_at BETWEEN <time> AND <time>.updated_at IS NULLandupdated_at IS NOT NULL.
score > 0.8, runs on the records the
search returns, as before. A filter that also names another column runs
there too.
Any other filter on updated_at alone is refused before the search runs,
with INVALID_ARGUMENT and the error code QL-PL-023
(UNSUPPORTED_SEARCH_FILTER). Examples are date_trunc('day', updated_at),
updated_at <> ..., and two ranges joined by OR. Applied after the
search, such a filter would see only the records the search chose, and a
narrow window would come back empty. The message starts with
search_everything: the filter, then names the filter as the engine
planned it, and ends with the forms to use, such as
updated_at >= now() - INTERVAL '30 days'. Preview a Plot answers it as
HTTP 400 with the same code and message.
The window compares the record’s time now, as the record is read again. A
record whose time moved out of the window since the index last saw it is
left out. The search also narrows its candidates by the time the index last
saw. So a record whose time moved into the window after the last index
build, such as an issue whose status changed since then, can be missing
until the next build.
Fresh records first
Give a half-life as the fourth argument to rank fresh records higher. The function then returns thelimit records of highest relevance:
relevance = score × (0.5 + 0.5 × 2^(−age / half_life))
ageis the query’s start time minusupdated_at. A time after the query’s start counts as age 0.- A record that changed one half-life ago keeps three quarters of its score. Age can at most halve a score, so an exact old match still ranks above a weak new one.
- A record with no
updated_atranks as the oldest: itsrelevanceis half itsscore. - A month in the half-life counts as 30 days, and a day as 24 hours.
scoredoes not change. It is still the best passage’s similarity.
NULL, relevance equals score, and the
function returns the same records in the same order as before.
With a half-life the search also looks for passages of records that changed
in the last two half-lives. So a fresh record that matches fairly well still
returns when many older passages match more closely. A
time window applies to both, so a half-life and a window work
together. An index built before the record time existed ranks only the
closest passages by relevance until its next build.
Join back
row_key is a JSON object of the source table’s key columns. A single text
key joins like this:
row_key is JSON text. json_get_str reads a text key; json_get_int reads
a numeric one. Use the names inside row_key. A record with more than one
key column matches each of them. The join reads the source table under the
same Provider Policies as any other query, so a record the search omitted
stays omitted.