PG search run
pg_search_runExecute a full-text BM25 search on a pg_search-indexed table, returning results with relevance scores and configurable snippet highlighting.
Instructions
Run a BM25 keyword search against a pg_search-indexed table. Returns hits as {id, score, snippets} where id is the value of the caller-supplied key_field and score is pdb.score(t). columns=None searches the whole index; columns=["col"] restricts to a single text field. Multi-column search needs the pdb.parse per-field config JSON and is deferred to a follow-up phase. return_snippets=True requires snippet_field and projects pdb.snippets over that column. Requires the pg_search extension. SECURITY: snippet_start_tag / snippet_end_tag are not sanitized (they pass through to upstream as-is). The defaults match pg_search's HTML defaults; if callers forward untrusted values and a downstream consumer renders snippets as HTML, that's an XSS vector — output escaping is the renderer's responsibility.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | Yes | ||
| query | Yes | ||
| table | Yes | ||
| schema | Yes | ||
| columns | No | ||
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. | |
| key_field | Yes | ||
| snippet_field | No | ||
| return_snippets | No | ||
| snippet_end_tag | No | </b> | |
| snippet_start_tag | No | <b> | |
| snippet_max_num_chars | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |