1 <!-- doc/src/sgml/dict-int.sgml -->
3 <sect1 id=
"dict-int" xreflabel=
"dict_int">
4 <title>dict_int
—
5 example full-text search dictionary for integers
</title>
7 <indexterm zone=
"dict-int">
8 <primary>dict_int
</primary>
12 <filename>dict_int
</filename> is an example of an add-on dictionary template
13 for full-text search. The motivation for this example dictionary is to
14 control the indexing of integers (signed and unsigned), allowing such
15 numbers to be indexed while preventing excessive growth in the number of
16 unique words, which greatly affects the performance of searching.
20 This module is considered
<quote>trusted
</quote>, that is, it can be
21 installed by non-superusers who have
<literal>CREATE
</literal> privilege
22 on the current database.
25 <sect2 id=
"dict-int-config">
26 <title>Configuration
</title>
29 The dictionary accepts three options:
35 The
<literal>maxlen
</literal> parameter specifies the maximum number of
36 digits allowed in an integer word. The default value is
6.
41 The
<literal>rejectlong
</literal> parameter specifies whether an overlength
42 integer should be truncated or ignored. If
<literal>rejectlong
</literal> is
43 <literal>false
</literal> (the default), the dictionary returns the first
44 <literal>maxlen
</literal> digits of the integer. If
<literal>rejectlong
</literal> is
45 <literal>true
</literal>, the dictionary treats an overlength integer as a stop
46 word, so that it will not be indexed. Note that this also means that
47 such an integer cannot be searched for.
52 The
<literal>absval
</literal> parameter specifies whether leading
53 <quote><literal>+
</literal></quote> or
<quote><literal>-
</literal></quote>
54 signs should be removed from integer words. The default
55 is
<literal>false
</literal>. When
<literal>true
</literal>, the sign is
56 removed before
<literal>maxlen
</literal> is applied.
62 <sect2 id=
"dict-int-usage">
66 Installing the
<literal>dict_int
</literal> extension creates a text search
67 template
<literal>intdict_template
</literal> and a dictionary
<literal>intdict
</literal>
68 based on it, with the default parameters. You can alter the
69 parameters, for example
72 mydb# ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN =
4, REJECTLONG = true);
73 ALTER TEXT SEARCH DICTIONARY
76 or create new dictionaries based on the template.
80 To test the dictionary, you can try
83 mydb# select ts_lexize('intdict', '
12345678');
89 but real-world usage will involve including it in a text search
90 configuration as described in
<xref linkend=
"textsearch"/>.
91 That might look like this:
94 ALTER TEXT SEARCH CONFIGURATION english
95 ALTER MAPPING FOR int, uint WITH intdict;