Highlighting is an expensive process and can slow down query times. We recommend passing a LIMIT to any query where paradedb.snippet is called to restrict the number of snippets that need to be generated.

Highlighting is not supported for paradedb.fuzzy_term and paradedb.fuzzy_phrase.

Highlighting refers to the practice of visually emphasizing the portions of a document that match a user’s search query. Highlighted snippets of text are by default wrapped in <b></b> tags. This can be modified with the start_tag and end_tag arguments.

Basic Usage

paradedb.snippet(<column>) can be added to any query where an @@@ operator is present. The following query generates highlighted snippets against the description field.

SELECT id, paradedb.snippet(description)
FROM mock_items
WHERE description @@@ 'shoes'
LIMIT 5;
start_tag
default: "<b>"

The leading indicator around the highlighted region.

end_tag
default: "</b>"

The trailing indicator around the highlighted region.

max_num_chars
default: 150

Max number of characters for a highlighted fragment.

By default, <b></b> encloses the snippet. This can be configured with start_tag and end_tag:

SELECT id, paradedb.snippet(description, start_tag => '<i>', end_tag => '</i>')
FROM mock_items
WHERE description @@@ 'shoes'
LIMIT 5;