# Served words

Every word the query service accepts, generated from the service's own word table.

This is the word table the service checks every query against. A word that is not here is refused by name before anything is read. The page uses a copy of the service's `words.json`. It was compared with query.words from the installed binary and the source word table for these pages.

## Reading records in

- `collection`: Read records from the named collection, including names that cannot be written bare. Arguments: name: a nonempty collection name in double quotes.
- `match`: Match a labelled collection or a fixed chain of directed relations first or immediately after its collection. Arguments: nodes: (binding:collection) or up to eight labelled nodes joined by directed relations; binding: distinct names matching [a-z_][a-z0-9_]*; relation: -[:kind]-> or <-[:kind]- at each of up to seven hops.
- `{ }`: Keep selected fields in record order; a first-stage shape reads collections in root order before worker Input. Arguments: fields: bare names with nested selection sets; source: one or several collection roots in a first-stage shape.


## Searching

- `similar`: Search by vector similarity first after its source or later over the records that reached it. Arguments: field: a top-level vector field with a leading dot; question: double-quoted text or record("id"); measure: cosine, l2 or dot.
- `record`: Use the stored vector of the named record as the similarity question. Arguments: id: a record id in double quotes.
- `cosine`: Compare vectors by their cosine similarity.
- `l2`: Compare vectors by their Euclidean distance.
- `dot`: Compare vectors by their dot product.
- `rg`: Keep whole records in order when their compact JSON or named field matches the pattern. Arguments: field: optional top-level field with a leading dot; pattern: a regular expression in double quotes; flags: optional quoted -i, -s, -S, -w, -x, -F, -v and -U switches and their long forms; --no-ignore-case resets case sensitivity; -U dot matches newlines.
- `grep`: Alias of rg: keep whole records in order when their compact JSON or named field matches the pattern. Arguments: field: optional top-level field with a leading dot; pattern: a regular expression in double quotes; flags: optional quoted -i, -s, -S, -w, -x, -F, -v and -U switches and their long forms; --no-ignore-case resets case sensitivity; -U dot matches newlines.


## Order and bound

- `limit`: Stop the upstream after at most n records or values at this point in the pipeline. Arguments: n: a whole number from 1 to 4294967295.
- `sort`: Order the whole upstream by a field before the quoted jq stage. Arguments: field: a top-level field with a leading dot; direction: optional desc after a semicolon.
- `desc`: Order the sort field from greatest to least instead of ascending order.
- `rerank`: Drain the bounded upstream, reorder by vector score, replace scores and count unscored records last; no continuation. Arguments: field: a top-level vector field with a leading dot; question: double-quoted text or record("id"); measure: cosine, l2 or dot.
- `window`: Keep records by their revision append version, never by a time inside the record. Arguments: from: an included unsigned version or quoted RFC 3339 instant; to: an excluded bound of the same form, or $now.


## One answer

- `count`: Consume the whole upstream and answer its size as the last stage.
- `group_by`: Drain records before jq into key, count and values groups in jq value order; missing fields group under null and no continuation is available. Arguments: field: a top-level field with a leading dot.
- `percentile`: Drain records before jq into one nearest-rank JSON number; empty numeric input gives null, zero selects the minimum, non-numbers are counted as skipped, and no continuation is available. Arguments: field: a top-level numeric field with a leading dot; percentile: a number from 0 to 100 inclusive.


## Reserved

- `sort_by` (not yet served): Reserve an unquoted sort_by stage that is not available yet. Arguments: expression: a sort key.


## Inside quoted jq

<Keywords />
