1<!-- doc/src/sgml/dict-int.sgml --> 2 3<sect1 id="dict-int" xreflabel="dict_int"> 4 <title>dict_int</title> 5 6 <indexterm zone="dict-int"> 7 <primary>dict_int</primary> 8 </indexterm> 9 10 <para> 11 <filename>dict_int</filename> 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. 16 </para> 17 18 <para> 19 This module is considered <quote>trusted</quote>, that is, it can be 20 installed by non-superusers who have <literal>CREATE</literal> privilege 21 on the current database. 22 </para> 23 24 <sect2> 25 <title>Configuration</title> 26 27 <para> 28 The dictionary accepts three options: 29 </para> 30 31 <itemizedlist> 32 <listitem> 33 <para> 34 The <literal>maxlen</literal> parameter specifies the maximum number of 35 digits allowed in an integer word. The default value is 6. 36 </para> 37 </listitem> 38 <listitem> 39 <para> 40 The <literal>rejectlong</literal> parameter specifies whether an overlength 41 integer should be truncated or ignored. If <literal>rejectlong</literal> is 42 <literal>false</literal> (the default), the dictionary returns the first 43 <literal>maxlen</literal> digits of the integer. If <literal>rejectlong</literal> is 44 <literal>true</literal>, the dictionary treats an overlength integer as a stop 45 word, so that it will not be indexed. Note that this also means that 46 such an integer cannot be searched for. 47 </para> 48 </listitem> 49 <listitem> 50 <para> 51 The <literal>absval</literal> parameter specifies whether leading 52 <quote><literal>+</literal></quote> or <quote><literal>-</literal></quote> 53 signs should be removed from integer words. The default 54 is <literal>false</literal>. When <literal>true</literal>, the sign is 55 removed before <literal>maxlen</literal> is applied. 56 </para> 57 </listitem> 58 </itemizedlist> 59 </sect2> 60 61 <sect2> 62 <title>Usage</title> 63 64 <para> 65 Installing the <literal>dict_int</literal> extension creates a text search 66 template <literal>intdict_template</literal> and a dictionary <literal>intdict</literal> 67 based on it, with the default parameters. You can alter the 68 parameters, for example 69 70<programlisting> 71mydb# ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = 4, REJECTLONG = true); 72ALTER TEXT SEARCH DICTIONARY 73</programlisting> 74 75 or create new dictionaries based on the template. 76 </para> 77 78 <para> 79 To test the dictionary, you can try 80 81<programlisting> 82mydb# select ts_lexize('intdict', '12345678'); 83 ts_lexize 84----------- 85 {123456} 86</programlisting> 87 88 but real-world usage will involve including it in a text search 89 configuration as described in <xref linkend="textsearch"/>. 90 That might look like this: 91 92<programlisting> 93ALTER TEXT SEARCH CONFIGURATION english 94 ALTER MAPPING FOR int, uint WITH intdict; 95</programlisting> 96 97 </para> 98 </sect2> 99 100</sect1> 101