4 <title>dict_xsyn
</title>
6 <indexterm zone=
"dict-xsyn">
7 <primary>dict_xsyn
</primary>
11 <filename>dict_xsyn<
/> (Extended Synonym Dictionary) is an example of an
12 add-on dictionary template for full-text search. This dictionary type
13 replaces words with groups of their synonyms, and so makes it possible to
14 search for a word using any of its synonyms.
18 <title>Configuration
</title>
21 A
<literal>dict_xsyn<
/> dictionary accepts the following options:
26 <literal>keeporig<
/> controls whether the original word is included (if
27 <literal>true<
/>), or only its synonyms (if
<literal>false<
/>). Default
33 <literal>rules<
/> is the base name of the file containing the list of
34 synonyms. This file must be stored in
35 <filename>$SHAREDIR/tsearch_data/<
/> (where
<literal>$SHAREDIR<
/> means
36 the
<productname>PostgreSQL<
/> installation's shared-data directory).
37 Its name must end in
<literal>.rules<
/> (which is not to be included in
38 the
<literal>rules<
/> parameter).
43 The rules file has the following format:
48 Each line represents a group of synonyms for a single word, which is
49 given first on the line. Synonyms are separated by whitespace, thus:
57 The sharp (
<literal>#<
/>) sign is a comment delimiter. It may appear at
58 any position in a line. The rest of the line will be skipped.
64 Look at
<filename>xsyn_sample.rules<
/>, which is installed in
65 <filename>$SHAREDIR/tsearch_data/<
/>, for an example.
73 Running the installation script creates a text search template
74 <literal>xsyn_template<
/> and a dictionary
<literal>xsyn<
/>
75 based on it, with default parameters. You can alter the
76 parameters, for example
79 mydb# ALTER TEXT SEARCH DICTIONARY xsyn (RULES='my_rules', KEEPORIG=false);
80 ALTER TEXT SEARCH DICTIONARY
83 or create new dictionaries based on the template.
87 To test the dictionary, you can try
90 mydb=# SELECT ts_lexize('xsyn', 'word');
92 -----------------------
96 but real-world usage will involve including it in a text search
97 configuration as described in
<xref linkend=
"textsearch">.
98 That might look like this:
101 ALTER TEXT SEARCH CONFIGURATION english
102 ALTER MAPPING FOR word, asciiword WITH xsyn, english_stem;