Skip to main content
To add synonyms to a query, use pdb.expand(<query>, <rule>), where
  • <query> is the query string
  • <rule> is the column containing the synonym rules.
For example, the following query replaces the query leather couch with its synonym set.
Under the hood, the query string passed into pdb.expand is first split into tokens using the field’s tokenizer (in this example, the tokenizer for description). Each token is then looked up against the synonym index for <rule>, and expanded into a synonym set if a match is found. The following queries support synonym expansion. If you require synonym support on additional query types, please open a GitHub issue.

Match Conjunction

&&& requires all synonym groups to match. Within each group, any alternative can match.

Match Disjunction

||| requires any synonym group to match. A match for any alternative in any group is enough.

Phrase

### requires all synonym groups to match together and in order. Each group can match any of its alternatives, including alternatives containing multiple words.
Like normal phrase queries, the subquery can be cast to ::pdb.slop(...).

Fuzzy Matching

Fuzzy matching applies to the search text, while synonyms remain exact matches. Synonym rules are looked up using the query tokens without fuzzy matching, so misspelled tokens do not match rule keys.

Query Parser

@@@ parses the query string before expanding its terms and quoted phrases. Boolean operators, grouping, and phrase constraints still apply to the expanded synonym groups. Use quotes around multi-word synonym keys so the parser treats them as a phrase.