Nei*_*gan 5 postgresql windows full-text-search
Postgres 可以在文本搜索中使用 Ispell 兼容的字典,但不提供所需的文件。
此示例使用加拿大英语词典,但您也可以与其他人一起尝试。
这些是 Windows 所需的步骤:
在 PgAdmin 中,运行以下 SQL:
create text search dictionary ispell_en_ca (
template = ispell,
dictfile = en_ca,
afffile = en_ca,
stopwords = english
);
--make sure it works:
select * from ts_lexize('ispell_en_ca', 'colours');
/*
result:
ts_lexize
text[]
{coloured,colour}
*/
Run Code Online (Sandbox Code Playgroud)
您需要创建一个新的文本搜索配置才能使用字典。
小智 7
我编写了以下脚本来在运行 PostgreSQL 9.4 的 Ubuntu 14.04 上安装 en_us 字典。在大多数情况下,它应该很容易修改。
#!/bin/bash
cd /usr/share/postgresql/9.4/tsearch_data
wget http://src.chromium.org/svn/trunk/deps/third_party/hunspell_dictionaries/en_US.dic
wget http://src.chromium.org/svn/trunk/deps/third_party/hunspell_dictionaries/en_US.dic_delta
wget http://src.chromium.org/svn/trunk/deps/third_party/hunspell_dictionaries/en_US.aff -O en_us.affix
# Remove first line
sed -i 1d en_US.dic
# Concat the dic and dic_delta, sort alphabetically and remove the leading blank line (leaves the ending newline intact)
cat en_US.dic en_US.dic_delta | sort > en_us.dict
sed -i 1d en_us.dict
# Set permissions
chown -R postgres:postgres *
sudo -u postgres psql -c "CREATE TEXT SEARCH DICTIONARY ispell_en_us (template = ispell, dictfile = en_us, afffile = en_us, stopwords = english);"
# Clean up source files
rm en_US*
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4901 次 |
最近记录: |