4 <title>dict_int
</title>
6 <indexterm zone=
"dict-int">
7 <primary>dict_int
</primary>
11 <filename>dict_int<
/> is an example of an add-on dictionary template
12 for full-text search. The motivation for this example dictionary is to
13 control the indexing of integers (signed and unsigned), allowing such
14 numbers to be indexed while preventing excessive growth in the number of
15 unique words, which greatly affects the performance of searching.
19 <title>Configuration
</title>
22 The dictionary accepts two options:
28 The
<literal>maxlen<
/> parameter specifies the maximum number of
29 digits allowed in an integer word. The default value is
6.
34 The
<literal>rejectlong<
/> parameter specifies whether an overlength
35 integer should be truncated or ignored. If
<literal>rejectlong<
/> is
36 <literal>false<
/> (the default), the dictionary returns the first
37 <literal>maxlen<
/> digits of the integer. If
<literal>rejectlong<
/> is
38 <literal>true<
/>, the dictionary treats an overlength integer as a stop
39 word, so that it will not be indexed. Note that this also means that
40 such an integer cannot be searched for.
50 Running the installation script creates a text search template
51 <literal>intdict_template<
/> and a dictionary
<literal>intdict<
/>
52 based on it, with the default parameters. You can alter the
53 parameters, for example
56 mydb# ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN =
4, REJECTLONG = true);
57 ALTER TEXT SEARCH DICTIONARY
60 or create new dictionaries based on the template.
64 To test the dictionary, you can try
67 mydb# select ts_lexize('intdict', '
12345678');
73 but real-world usage will involve including it in a text search
74 configuration as described in
<xref linkend=
"textsearch">.
75 That might look like this:
78 ALTER TEXT SEARCH CONFIGURATION english
79 ALTER MAPPING FOR int, uint WITH intdict;