RefLib

Reference library for AI

Back

postgresql_16:9.6.14.2 Usage

PostgreSQL 16 > Appendixes > Additional Supplied Modules and Extensions > dict_xsyn — example synonym full-text search dictionary > Usage

Installing the dict_xsyn extension creates a text search template xsyn_template and a dictionary xsyn based on it, with default parameters. You can alter the parameters, for example mydb# ALTER TEXT SEARCH DICTIONARY xsyn (RULES='my_rules', KEEPORIG=false); ALTER TEXT SEARCH DICTIONARY or create new dictionaries based on the template.

To test the dictionary, you can try mydb=# SELECT ts_lexize('xsyn', 'word'); ts_lexize ----------------------- {syn1,syn2,syn3} mydb# ALTER TEXT SEARCH DICTIONARY xsyn (RULES='my_rules', KEEPORIG=true); ALTER TEXT SEARCH DICTIONARY mydb=# SELECT ts_lexize('xsyn', 'word'); ts_lexize ----------------------- {word,syn1,syn2,syn3} mydb# ALTER TEXT SEARCH DICTIONARY xsyn (RULES='my_rules', KEEPORIG=false, MATCHSYNONYMS=true); ALTER TEXT SEARCH DICTIONARY mydb=# SELECT ts_lexize('xsyn', 'syn1'); ts_lexize ----------------------- {syn1,syn2,syn3} mydb# ALTER TEXT SEARCH DICTIONARY xsyn (RULES='my_rules', KEEPORIG=true, MATCHORIG=false, KEEPSYNONYMS=false); ALTER TEXT SEARCH DICTIONARY mydb=# SELECT ts_lexize('xsyn', 'syn1'); ts_lexize ----------------------- {word} Real-world usage will involve including it in a text search configuration as described in (see postgresql_16:3.9). That might look like this: ALTER TEXT SEARCH CONFIGURATION english ALTER MAPPING FOR word, asciiword WITH xsyn, english_stem;

Back