> ## Documentation Index
> Fetch the complete documentation index at: https://www.paradedb.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL Function Reference

> User-facing SQL functions exposed by ParadeDB and pg_search

This page lists the callable, user-facing SQL functions and function-like casts that make up ParadeDB's SQL API. It intentionally omits planner support functions, type input/output functions such as `pdb.simple_in`, and generated cast helper names. Use the casts documented here instead of calling those helpers directly.

Older `paradedb.*` query builders and scoring functions are also intentionally omitted because `pdb.*` supersedes them.

Use `pdb` for query builders, scoring, and aggregates. Tokenizer utilities use `paradedb`. Index diagnostics and maintenance functions span both schemas, as listed below.

## Query Builders

Query builders return a ParadeDB query object for the right-hand side of `@@@`.

| Function | Signature | Use | Reference |
| - | - | - | - |
| `pdb.all` | `pdb.all()` | Match every row in the index. | [All](https://www.paradedb.com/docs/reference/full-text/all.md) |
| `pdb.empty` | `pdb.empty()` | Match no rows. Mostly useful for generated SQL. | This page |
| `pdb.exists` | `pdb.exists()` | Match rows where the field exists in the index. | [Filtering](https://www.paradedb.com/docs/reference/filtering/overview.md) |
| `pdb.parse` | `pdb.parse(query_string text, lenient bool default null, conjunction_mode bool default null)` | Parse Lucene/Tantivy-style query syntax. | [Query Parser](https://www.paradedb.com/docs/reference/full-text/query-parser.md) |
| `pdb.parse_with_field` | `pdb.parse_with_field(query_string text, lenient bool default null, conjunction_mode bool default null)` | Parse query syntax relative to the field on the left side of `@@@`. Usually produced by planner rewrites. | [Query Parser](https://www.paradedb.com/docs/reference/full-text/query-parser.md) |
| `pdb.match` | `pdb.match(value text, tokenizer jsonb default null, distance int default null, transposition_cost_one bool default null, prefix bool default null, conjunction_mode bool default null)` | Tokenized match with optional tokenizer, fuzzy, prefix, and conjunction controls. | [Match](https://www.paradedb.com/docs/reference/full-text/match.md) |
| `pdb.match_disjunction` | `pdb.match_disjunction(text)` or `pdb.match_disjunction(text[])` | Match any token. Equivalent to the match-disjunction operator. | [Match Disjunction](https://www.paradedb.com/docs/reference/full-text/match.md#match-disjunction) |
| `pdb.match_conjunction` | `pdb.match_conjunction(text)` or `pdb.match_conjunction(text[])` | Match all tokens. Equivalent to `&&&`. | [Match Conjunction](https://www.paradedb.com/docs/reference/full-text/match.md#match-conjunction) |
| `pdb.fuzzy_term` | `pdb.fuzzy_term(value text default null, distance int default null, transposition_cost_one bool default null, prefix bool default null)` | Build a fuzzy exact-token query. Most users use `=== ...::pdb.fuzzy(...)` instead. | [Fuzzy](https://www.paradedb.com/docs/reference/full-text/fuzzy.md) |
| `pdb.term` | `pdb.term(value)` | Match an exact indexed token or scalar value. | [Term](https://www.paradedb.com/docs/reference/full-text/term.md) |
| `pdb.term_set` | `pdb.term_set(values[])` | Match any exact value from an array. | [Term](https://www.paradedb.com/docs/reference/full-text/term.md#term-set) |
| `pdb.range` | `pdb.range(range)` | Match values inside a Postgres range. | [Filtering](https://www.paradedb.com/docs/reference/filtering/overview.md) |
| `pdb.range_term` | `pdb.range_term(value)` or `pdb.range_term(range, relation)` | Search Postgres range fields by contained term or range relation. | [Range Term](https://www.paradedb.com/docs/reference/full-text/range-term.md) |
| `pdb.phrase` | `pdb.phrase(text)` or `pdb.phrase(text[], slop int default null)` | Match tokens in order and position. Equivalent to `###`. | [Phrase](https://www.paradedb.com/docs/reference/full-text/phrase.md) |
| `pdb.phrase_array` | `pdb.phrase_array(text[])` | Pretokenized phrase match. | [Phrase](https://www.paradedb.com/docs/reference/full-text/phrase.md#using-pretokenized-text) |
| `pdb.phrase_prefix` | `pdb.phrase_prefix(text[], max_expansion int default null)` | Phrase query where the final token is a prefix. | [Phrase Prefix](https://www.paradedb.com/docs/reference/full-text/phrase-prefix.md) |
| `pdb.regex` | `pdb.regex(pattern text)` | Match indexed terms with a regex. | [Regex](https://www.paradedb.com/docs/reference/full-text/regex.md) |
| `pdb.regex_phrase` | `pdb.regex_phrase(regexes text[], slop int default null, max_expansions int default null)` | Match a phrase made of regex terms. | [Regex Phrase](https://www.paradedb.com/docs/reference/full-text/regex-phrase.md) |
| `pdb.more_like_this` | `pdb.more_like_this(key_value anyelement, fields text[] default null, ...)` | Find rows similar to an indexed row. | [More Like This](https://www.paradedb.com/docs/reference/full-text/more-like-this.md) |
| `pdb.more_like_this` | `pdb.more_like_this(document text, ...)` | Find rows similar to a JSON document string. | [More Like This](https://www.paradedb.com/docs/reference/full-text/more-like-this.md#using-a-custom-input-document) |

`pdb.term`, `pdb.term_set`, `pdb.range`, and `pdb.range_term` are overloaded for supported Postgres scalar and range types.

The aggregate form `pdb.term_set(value bigint)` still exists for compatibility, but new queries should use `pdb.term_set(array_agg(...))` instead.

## Query Modifier Casts

Modifier casts attach scoring, fuzzy, or slop settings to another query expression.

| Cast or typmod | Use | Reference |
| - | - | - |
| `::pdb.fuzzy(distance, prefix, transposition_cost_one)` | Allow edit-distance matching for match and term queries. | [Fuzzy](https://www.paradedb.com/docs/reference/full-text/fuzzy.md) |
| `::pdb.boost(factor)` | Multiply a query's contribution to BM25 score. | [Relevance Tuning](https://www.paradedb.com/docs/reference/full-text/relevance-tuning.md) |
| `::pdb.const(score)` | Assign a constant score to a query. | [Constant Scoring](https://www.paradedb.com/docs/reference/full-text/relevance-tuning.md#constant-scoring) |
| `::pdb.slop(distance)` | Allow gaps or transpositions in phrase queries. | [Phrase Slop](https://www.paradedb.com/docs/reference/full-text/phrase.md#adding-slop) |

## Proximity Builders

These functions create proximity clauses for `@@@`.

| Function | Signature | Use | Reference |
| - | - | - | - |
| `pdb.prox_term` | `pdb.prox_term(term text)` | Create a single proximity term. | [Proximity](https://www.paradedb.com/docs/reference/full-text/proximity.md) |
| `pdb.prox_regex` | `pdb.prox_regex(regex text, max_expansions int default 50)` | Create a regex proximity term. | [Proximity Regex](https://www.paradedb.com/docs/reference/full-text/proximity.md#proximity-regex) |
| `pdb.prox_array` | `pdb.prox_array(variadic clauses)` | Match any of several proximity terms or clauses. | [Proximity Array](https://www.paradedb.com/docs/reference/full-text/proximity.md#proximity-array) |
| `pdb.prox_clause` | `pdb.prox_clause(left, distance int, right)` | Build an unordered proximity clause. | [Proximity](https://www.paradedb.com/docs/reference/full-text/proximity.md) |
| `pdb.prox_clause_in_order` | `pdb.prox_clause_in_order(left, distance int, right)` | Build an ordered proximity clause. | [Proximity](https://www.paradedb.com/docs/reference/full-text/proximity.md) |
| `pdb.proximity` | `pdb.proximity(proximity_clause)` or `pdb.proximity(left, distance int, right)` | Convert a proximity clause into a query builder result. | [Proximity](https://www.paradedb.com/docs/reference/full-text/proximity.md) |
| `pdb.proximity_in_order` | `pdb.proximity_in_order(left, distance int, right)` | Convert an ordered proximity clause into a query builder result. | [Proximity](https://www.paradedb.com/docs/reference/full-text/proximity.md) |

The symbolic `##` and `##>` operators are usually more concise than these function forms.

## Scoring and Highlighting

These functions are placeholders that ParadeDB's custom scan resolves during query execution. Use them in queries that also contain a ParadeDB predicate.

| Function | Signature | Use | Reference |
| - | - | - | - |
| `pdb.score` | `pdb.score(column anyelement) -> float4` | Return the BM25 score for a matched row. | [BM25 Scoring](https://www.paradedb.com/docs/reference/full-text/score.md) |
| `pdb.snippet` | `pdb.snippet(field anyelement, start_tag text default '<b>', end_tag text default '</b>', max_num_chars int default 150, limit int default null, offset int default null) -> text` | Return the best highlighted text snippet. | [Highlighting](https://www.paradedb.com/docs/reference/full-text/highlight.md) |
| `pdb.snippets` | `pdb.snippets(field anyelement, start_tag text default '<b>', end_tag text default '</b>', max_num_chars int default 150, limit int default null, offset int default null, sort_by text default 'score') -> text[]` | Return multiple highlighted snippets. | [Highlighting](https://www.paradedb.com/docs/reference/full-text/highlight.md#multiple-snippets) |
| `pdb.snippet_positions` | `pdb.snippet_positions(field anyelement, limit int default null, offset int default null) -> int[]` | Return byte offsets for highlighted snippets. | [Highlighting](https://www.paradedb.com/docs/reference/full-text/highlight.md#byte-offsets) |

## Aggregates

| Function | Signature | Use | Reference |
| - | - | - | - |
| `pdb.agg` | `pdb.agg(agg jsonb) -> jsonb` | Execute an Elasticsearch-compatible aggregate inside ParadeDB's aggregate scan. | [Aggregate Syntax](https://www.paradedb.com/docs/reference/aggregates/overview.md) |
| `pdb.agg` | `pdb.agg(agg jsonb, visibility text) -> jsonb` | Choose `transaction`, `raw`, or `threshold` visibility. Omitting visibility uses `transaction`. | [Aggregate Syntax](https://www.paradedb.com/docs/reference/aggregates/overview.md) |
| `pdb.combine_agg` | `pdb.combine_agg(agg jsonb) -> jsonb` | Combine grouped facets using `pdb.combine_agg(pdb.agg(...)) OVER ()`. | [Facets with GROUP BY](https://www.paradedb.com/docs/reference/aggregates/facets.md#facets-with-group-by) |

`paradedb.aggregate()` requires schema `USAGE`, table-level `SELECT`, and no active
row-level security for the effective caller. Metadata APIs (schema and field
configuration, layer sizes, creation details, merge/vacuum/FSM status, segment
counts, and `pdb.indexes()`) also allow callers with `pg_stat_scan_tables`
privileges, inherited by `pg_monitor`. Those roles can see whole-index metadata
and counts under RLS, but this exception does not authorize document reads or
verification. `merge_lock_garbage_collect()` instead requires table `MAINTAIN`
on PostgreSQL 17+, including `pg_maintain`, or table ownership on older versions.

Supported aggregate JSON shapes are documented under [Aggregates](https://www.paradedb.com/docs/reference/aggregates/overview.md), including [terms](https://www.paradedb.com/docs/reference/aggregates/bucket/terms.md), [range](https://www.paradedb.com/docs/reference/aggregates/bucket/range.md), [histogram](https://www.paradedb.com/docs/reference/aggregates/bucket/histogram.md), [date histogram](https://www.paradedb.com/docs/reference/aggregates/bucket/datehistogram.md), [filters](https://www.paradedb.com/docs/reference/aggregates/bucket/filters.md), [sum](https://www.paradedb.com/docs/reference/aggregates/metrics/sum.md), [average](https://www.paradedb.com/docs/reference/aggregates/metrics/average.md), [min/max](https://www.paradedb.com/docs/reference/aggregates/metrics/minmax.md), [count](https://www.paradedb.com/docs/reference/aggregates/metrics/count.md), [stats](https://www.paradedb.com/docs/reference/aggregates/metrics/stats.md), [percentiles](https://www.paradedb.com/docs/reference/aggregates/metrics/percentiles.md), [cardinality](https://www.paradedb.com/docs/reference/aggregates/metrics/cardinality.md), and [top hits](https://www.paradedb.com/docs/reference/aggregates/metrics/tophits.md).

## Tokenizer Utilities

| Function | Signature | Use | Reference |
| - | - | - | - |
| `paradedb.tokenizer` | `paradedb.tokenizer(name text, remove_long int default 255, lowercase bool default true, min_gram int default null, max_gram int default null, prefix_only bool default null, language text default null, pattern text default null, stemmer text default null, stopwords_language text default null, stopwords_languages text[] default null, stopwords text[] default null, ascii_folding bool default null) -> jsonb` | Build JSON tokenizer configuration for `pdb.match` or `paradedb.tokenize`. | [Tokenizers](https://www.paradedb.com/docs/reference/tokenizers/overview.md) |
| `paradedb.tokenize` | `paradedb.tokenize(tokenizer_setting jsonb, input_text text) -> table(token text, position int)` | Preview tokenizer output for a tokenizer configuration. | [Tokenizers](https://www.paradedb.com/docs/reference/tokenizers/overview.md) |
| `paradedb.tokenizers` | `paradedb.tokenizers() -> table(tokenizer text)` | List tokenizer names available to `paradedb.tokenizer`. | [Tokenizers](https://www.paradedb.com/docs/reference/tokenizers/overview.md) |

ParadeDB also generates cast-support helpers such as `pdb.tokenize_simple`, `pdb.tokenize_icu`, `pdb.tokenize_ngram`, and `pdb.tokenize_edge_ngram`. Use tokenizer casts or `paradedb.tokenize(...)` instead of calling these generated helpers directly.

## Index Diagnostics and Maintenance

| Function | Signature | Use | Reference |
| - | - | - | - |
| `paradedb.schema` | `paradedb.schema(index regclass) -> table(...)` | Inspect the fields, field types, and tokenizer settings stored in an index schema. | [Create Index](https://www.paradedb.com/docs/reference/indexing/create-index.md) |
| `paradedb.index_fields` | `paradedb.index_fields(index regclass) -> jsonb` | Return the stored field configuration for an index. | [Create Index](https://www.paradedb.com/docs/reference/indexing/create-index.md) |
| `pdb.verify_index` | `pdb.verify_index(index regclass, heapallindexed bool default false, sample_rate float8 default null, report_progress bool default false, verbose bool default false, on_error_stop bool default false, segment_ids int[] default null)` | Verify one ParadeDB index. | [Verify Index Integrity](https://www.paradedb.com/docs/operate/index-maintenance/verify-index.md) |
| `pdb.verify_all_indexes` | `pdb.verify_all_indexes(schema_pattern text default null, index_pattern text default null, heapallindexed bool default false, sample_rate float8 default null, report_progress bool default false, on_error_stop bool default false)` | Verify all ParadeDB indexes in a database, optionally filtered by pattern. | [Verify Index Integrity](https://www.paradedb.com/docs/operate/index-maintenance/verify-index.md) |
| `pdb.index_segments` | `pdb.index_segments(index regclass)` | List segment-level metadata for one index. | [Verify Index Integrity](https://www.paradedb.com/docs/operate/index-maintenance/verify-index.md) |
| `pdb.indexes` | `pdb.indexes()` | List ParadeDB indexes in the current database. | [Verify Index Integrity](https://www.paradedb.com/docs/operate/index-maintenance/verify-index.md) |
| `paradedb.index_info` | `paradedb.index_info(index regclass, show_invisible bool default false) -> table(...)` | Inspect per-segment visibility, size, and Tantivy component statistics. | [Verify Index Integrity](https://www.paradedb.com/docs/operate/index-maintenance/verify-index.md) |
| `paradedb.vector_info` | `paradedb.vector_info(index regclass, field text) -> table(...)` | Inspect per-segment vector storage statistics for one vector field. | [Tuning Recall and Latency](https://www.paradedb.com/docs/reference/vector/tuning.md) |
| `paradedb.vector_config` | `paradedb.vector_config(index regclass, field text) -> table(index_oid oid, quantized boolean, layers integer[], bytes_per_row integer, settings_version integer)` | Inspect the quantization build target for each leaf index. | [Tuning Recall and Latency](https://www.paradedb.com/docs/reference/vector/tuning.md) |
| `paradedb.vector_clusters` | `paradedb.vector_clusters(index regclass, field text) -> table(...)` | Inspect IVF cluster sizes for one vector field. | [Tuning Recall and Latency](https://www.paradedb.com/docs/reference/vector/tuning.md) |
| `paradedb.merge_info` | `paradedb.merge_info(index regclass) -> table(...)` | Inspect active or pending segment merge entries. | [Index Maintenance](https://www.paradedb.com/docs/operate/index-maintenance/reindexing.md) |
| `paradedb.vacuum_info` | `paradedb.vacuum_info(index regclass) -> table(...)` | Inspect segments queued for vacuum cleanup. | [Index Maintenance](https://www.paradedb.com/docs/operate/index-maintenance/reindexing.md) |
| `paradedb.layer_sizes` | `paradedb.layer_sizes(index regclass) -> numeric[]` | Return foreground merge layer thresholds for an index. | [Index Maintenance](https://www.paradedb.com/docs/operate/index-maintenance/reindexing.md) |
| `paradedb.background_layer_sizes` | `paradedb.background_layer_sizes(index regclass) -> numeric[]` | Return background merge layer thresholds for an index. | [Index Maintenance](https://www.paradedb.com/docs/operate/index-maintenance/reindexing.md) |
| `paradedb.combined_layer_sizes` | `paradedb.combined_layer_sizes(index regclass) -> numeric[]` | Return combined foreground and background merge layer thresholds. | [Index Maintenance](https://www.paradedb.com/docs/operate/index-maintenance/reindexing.md) |
| `paradedb.storage_info` | `paradedb.storage_info(index regclass) -> table(block bigint, max_offset int)` | Inspect low-level metadata storage pages. | [Verify Index Integrity](https://www.paradedb.com/docs/operate/index-maintenance/verify-index.md) |
| `paradedb.page_info` | `paradedb.page_info(index regclass, blockno bigint) -> table(...)` | Inspect one low-level metadata storage page. | [Verify Index Integrity](https://www.paradedb.com/docs/operate/index-maintenance/verify-index.md) |
| `paradedb.find_ctid` | `paradedb.find_ctid(index regclass, ctid tid) -> text[]` | Find segment IDs containing one heap tuple identifier. | [Verify Index Integrity](https://www.paradedb.com/docs/operate/index-maintenance/verify-index.md) |
| `paradedb.index_created_at` | `paradedb.index_created_at(index regclass) -> timestamptz` | Return when an index was built, or `NULL` for older indexes. | [Verify Index Integrity](https://www.paradedb.com/docs/operate/index-maintenance/verify-index.md#inspecting-index-creation-time) |
| `paradedb.index_created_by` | `paradedb.index_created_by(index regclass) -> text` | Return the pg\_search version that built the index, or `NULL` for older indexes. | [Verify Index Integrity](https://www.paradedb.com/docs/operate/index-maintenance/verify-index.md#inspecting-index-creation-time) |
| `paradedb.version_info` | `paradedb.version_info() -> table(version text, build_mode text)` | Show the installed pg\_search version and build mode. | This page |
| `paradedb.merge_lock_garbage_collect` | `paradedb.merge_lock_garbage_collect(index regclass) -> setof int` | Clear stale merge-lock entries and return affected process IDs. | [Index Maintenance](https://www.paradedb.com/docs/operate/index-maintenance/reindexing.md) |

Related views:

| View | Use |
| - | - |
| `pdb.index_layer_info` | Show index segments grouped into foreground and background merge layers. |

## Tokenizer Casts

Tokenizer configuration is usually expressed through casts when creating an index or issuing tokenizer-specific queries.

| Cast or typmod | Use | Reference |
| - | - | - |
| `::pdb.simple(...)` | Default configurable tokenizer with filters such as stemming and stopwords. | [Simple](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/simple.md) |
| `::pdb.icu(...)` | ICU tokenizer for multilingual text. | [ICU](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/icu.md) |
| `::pdb.ngram(...)` | N-gram tokenization. | [Ngrams](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/ngrams.md) |
| `::pdb.edge_ngram(...)` | Prefix-oriented n-gram tokenization. | [Edge Ngrams](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/edge-ngrams.md) |
| `::pdb.whitespace` | Whitespace tokenization. | [Whitespace](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/whitespace.md) |
| `::pdb.literal` | Treat the whole text value as one token. | [Literal](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/literal.md) |
| `::pdb.literal_normalized` | Literal tokenization with normalization. | [Literal Normalized](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/literal-normalized.md) |
| `::pdb.regex_pattern(...)` | Regex-based tokenization. | [Regex Tokenizer](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/regex.md) |
| `::pdb.source_code` | Source-code tokenization. | [Source Code](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/source-code.md) |
| `::pdb.unicode_words` | Unicode word tokenization. | [Unicode](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/unicode.md) |
| `::pdb.jieba(...)` | Chinese tokenization with Jieba. | [Jieba](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/jieba.md) |
| `::pdb.lindera(...)` | Japanese/Korean tokenization with Lindera. | [Lindera](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/lindera.md) |
| `::pdb.chinese_compatible` | Chinese-compatible tokenizer. | [Chinese Compatible](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/chinese-compatible.md) |
| `::pdb.alias(...)` | Assign an indexed expression a queryable field name. | [Indexing Expressions](https://www.paradedb.com/docs/reference/indexing/indexing-expressions.md) |

## Deprecated Maintenance Functions

| Deprecated name | Replacement |
| - | - |
| `paradedb.is_merging` | `paradedb.merge_info` |
| `paradedb.validate_checksum` | `pdb.verify_index` |
| `paradedb.force_merge` | `VACUUM` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.