Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
F.24. Hunspell Dictionaries Modules
Prev UpAppendix F. Additional Supplied Modules and Extensions Shipped inpostgrespro-std-17-contribHome Next

F.24. Hunspell Dictionaries Modules#

These modules provideHunspell dictionaries for various languages. Upon installation of the module into database usingCREATE EXTENSION command, text search dictionary and configuration objects in the public schema appear.

Table F.12. Modules

LanguageExtension nameDictionary nameConfiguration name
American Englishhunspell_en_usenglish_hunspellenglish_hunspell
Dutchhunspell_nl_nldutch_hunspelldutch_hunspell
Frenchhunspell_frfrench_hunspellfrench_hunspell
Russianhunspell_ru_rurussian_hunspellrussian_hunspell

F.24.1. Examples#

Text search objects will be created after installation of a dictionary module. We can test created configuration:

SELECT * FROM ts_debug('english_hunspell', 'abilities');   alias   |   description   |   token   |          dictionaries           |    dictionary    |  lexemes  -----------+-----------------+-----------+---------------------------------+------------------+----------- asciiword | Word, all ASCII | abilities | {english_hunspell,english_stem} | english_hunspell | {ability}(1 row)

Or you can create your own text search configuration. For example, with the created dictionaries and with theSnowball dictionary you can create mixed russian-english configuration:

CREATE TEXT SEARCH CONFIGURATION russian_en (  COPY = simple);ALTER TEXT SEARCH CONFIGURATION russian_en  ALTER MAPPING FOR asciiword, asciihword, hword_asciipart  WITH english_hunspell, english_stem;ALTER TEXT SEARCH CONFIGURATION russian_en  ALTER MAPPING FOR word, hword, hword_part  WITH russian_hunspell, russian_stem;

You can create mixed dictionaries only for languages with different alphabets. If languages have similar alphabets thenPostgres Pro can not decide which dictionary should be used.

A text search configuration which is created with a dictionary module is ready to use. For example, in this text you can search some words:

SELECT to_tsvector('english_hunspell', 'The blue whale is the largest animal');               to_tsvector               ----------------------------------------- 'animal':7 'blue':2 'large':6 'whale':3(1 row)

Search query might looks like this:

SELECT to_tsvector('english_hunspell', 'The blue whale is the largest animal')  @@ to_tsquery('english_hunspell', 'large & whale'); ?column? ---------- t(1 row)

With this configurations you can search a text using GIN or GIST indexes. For example, there is a table with GIN index:

CREATE TABLE table1 (t varchar);INSERT INTO table1 VALUES ('The blue whale is the largest animal');CREATE INDEX t_idx ON table1 USING GIN (to_tsvector('english_hunspell', "t"));

For this table you can execute the following query:

SELECT * FROM table1 where to_tsvector('english_hunspell', t)  @@ to_tsquery('english_hunspell', 'blue & animal');                  t                   -------------------------------------- The blue whale is the largest animal(1 row)


Prev Up Next
F.23. hstore — hstore key/value datatype Home F.25. hypopg — support for hypothetical indexes
pdfepub
Go to Postgres Pro Standard 17
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp