2 F.12. dict_int — example full-text search dictionary for integers #
7 dict_int is an example of an add-on dictionary template for full-text
8 search. The motivation for this example dictionary is to control the
9 indexing of integers (signed and unsigned), allowing such numbers to be
10 indexed while preventing excessive growth in the number of unique
11 words, which greatly affects the performance of searching.
13 This module is considered “trusted”, that is, it can be installed by
14 non-superusers who have CREATE privilege on the current database.
16 F.12.1. Configuration #
18 The dictionary accepts three options:
19 * The maxlen parameter specifies the maximum number of digits allowed
20 in an integer word. The default value is 6.
21 * The rejectlong parameter specifies whether an overlength integer
22 should be truncated or ignored. If rejectlong is false (the
23 default), the dictionary returns the first maxlen digits of the
24 integer. If rejectlong is true, the dictionary treats an overlength
25 integer as a stop word, so that it will not be indexed. Note that
26 this also means that such an integer cannot be searched for.
27 * The absval parameter specifies whether leading “+” or “-” signs
28 should be removed from integer words. The default is false. When
29 true, the sign is removed before maxlen is applied.
33 Installing the dict_int extension creates a text search template
34 intdict_template and a dictionary intdict based on it, with the default
35 parameters. You can alter the parameters, for example
36 mydb# ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = 4, REJECTLONG = true);
37 ALTER TEXT SEARCH DICTIONARY
39 or create new dictionaries based on the template.
41 To test the dictionary, you can try
42 mydb# select ts_lexize('intdict', '12345678');
47 but real-world usage will involve including it in a text search
48 configuration as described in Chapter 12. That might look like this:
49 ALTER TEXT SEARCH CONFIGURATION english
50 ALTER MAPPING FOR int, uint WITH intdict;