Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
F.12. dict_int — example full-text search dictionary for integers
Prev UpAppendix F. Additional Supplied Modules and ExtensionsHome Next

F.12. dict_int — example full-text search dictionary for integers#

dict_int is an example of an add-on dictionary template for full-text search. The motivation for this example dictionary is to control the indexing of integers (signed and unsigned), allowing such numbers to be indexed while preventing excessive growth in the number of unique words, which greatly affects the performance of searching.

This module is consideredtrusted, that is, it can be installed by non-superusers who haveCREATE privilege on the current database.

F.12.1. Configuration#

The dictionary accepts three options:

  • Themaxlen parameter specifies the maximum number of digits allowed in an integer word. The default value is 6.

  • Therejectlong parameter specifies whether an overlength integer should be truncated or ignored. Ifrejectlong isfalse (the default), the dictionary returns the firstmaxlen digits of the integer. Ifrejectlong istrue, the dictionary treats an overlength integer as a stop word, so that it will not be indexed. Note that this also means that such an integer cannot be searched for.

  • Theabsval parameter specifies whether leading+ or- signs should be removed from integer words. The default isfalse. Whentrue, the sign is removed beforemaxlen is applied.

F.12.2. Usage#

Installing thedict_int extension creates a text search templateintdict_template and a dictionaryintdict based on it, with the default parameters. You can alter the parameters, for example

mydb# ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = 4, REJECTLONG = true);ALTER TEXT SEARCH DICTIONARY

or create new dictionaries based on the template.

To test the dictionary, you can try

mydb# select ts_lexize('intdict', '12345678'); ts_lexize----------- {123456}

but real-world usage will involve including it in a text search configuration as described inChapter 12. That might look like this:

ALTER TEXT SEARCH CONFIGURATION english    ALTER MAPPING FOR int, uint WITH intdict;


Prev Up Next
dblink_build_sql_update Home F.13. dict_xsyn — example synonym full-text search dictionary
pdfepub
Go to PostgreSQL 17
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp