]> begriffs open source - ai-pg/blob - full-docs/txt/dict-int.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / dict-int.txt
1
2 F.12. dict_int — example full-text search dictionary for integers #
3
4    F.12.1. Configuration
5    F.12.2. Usage
6
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.
12
13    This module is considered “trusted”, that is, it can be installed by
14    non-superusers who have CREATE privilege on the current database.
15
16 F.12.1. Configuration #
17
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.
30
31 F.12.2. Usage #
32
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
38
39    or create new dictionaries based on the template.
40
41    To test the dictionary, you can try
42 mydb# select ts_lexize('intdict', '12345678');
43  ts_lexize
44 -----------
45  {123456}
46
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;