PostgreSQL全文搜索缩写

编程入门 行业动态 更新时间:2024-10-25 14:32:07
本文介绍了PostgreSQL全文搜索缩写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用德语创建了Postgresql全文搜索。当我搜索 Bezirk时,该如何配置包含 Bez的行。也是比赛吗? (反之亦然)

I created a Postgresql full text search using 'german'. How can I configer, that when I search for "Bezirk", lines containing "Bez." are also a match? (And vice-versa)

推荐答案

@pozs是正确的。您需要使用同义词字典。

@pozs is right. You need to use a synonym dictionary.

1-在$ SHAREDIR / tsearch_data目录中,创建文件german.syn,其内容如下:

1 - In the directory $SHAREDIR/tsearch_data create the file german.syn with the following contents:

Bez Bezirk

2-执行查询:

CREATE TEXT SEARCH DICTIONARY german_syn ( template = synonym, synonyms = german); CREATE TEXT SEARCH CONFIGURATION german_syn(COPY='simple'); ALTER TEXT SEARCH CONFIGURATION german_syn ALTER MAPPING FOR asciiword, asciihword, hword_asciipart, word, hword, hword_part WITH german_syn, german_stem;

现在您可以对其进行测试。执行查询:

Now you can test it. Execute queries:

test=# SELECT to_tsvector('german_syn', 'Bezirk') @@ to_tsquery('german_syn', 'Bezirk & Bez'); ?column? ---------- t (1 row) test=# SELECT to_tsvector('german_syn', 'Bez Bez.') @@ to_tsquery('german_syn', 'Bezirk'); ?column? ---------- t (1 row)

附加链接:

  • PostgreSQL:全文搜索引擎 (已过期)
  • 更多推荐

    PostgreSQL全文搜索缩写

    本文发布于:2023-10-25 18:24:39,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1527731.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:缩写   全文   PostgreSQL

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!