本文介绍了PostGresqL全文搜索字符问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我的问题是:我正在用法语字典
使用postgresql的全文搜索,并且在我的数据库中有一些描述包含带有一个字符的名称,例如:
Amphi 'A',Amphi'C,Amphi'D'...
,那么,当我使用tsvector auto创建触发器时,索姆名不会出现,Amphi AI
得到'amphi' :1'a':2但Amphi'C'是'amphi':1,没有它的名字。

Well my problem is : I am using the full-text search of postgresql with a french dictionnary,and I have in my data base some descriptions that contains names with one character for exemple :Amphi 'A' , Amphi 'C, Amphi 'D' ...well, for that, when I use tsvector auto creation trigger, somme names don't appear,for Amphi A I got 'amphi':1 'a':2 but for Amphi 'C' is 'amphi':1 without the it's name.

请帮我:D

推荐答案

那是因为f.ex 。 C D 被认为是

That's because f.ex. C and D considered to be stop words in the french dictionary:

SELECT to_tsvector('french', 'Amphi A'); -- 'a':2 'amphi':1
SELECT to_tsvector('french', 'Amphi C'); -- 'amphi':1

您可以创建自定义字典(& a配置)而不被停止词:

You can create a custom dictionary (& a configuration for that) without stop words by:

CREATE TEXT SEARCH DICTIONARY french_stem_nostop(
    TEMPLATE = snowball,
    LANGUAGE = 'french'
);

CREATE TEXT SEARCH CONFIGURATION french_nostop(COPY = french);
ALTER TEXT SEARCH CONFIGURATION french_nostop
    ALTER MAPPING FOR asciihword WITH french_stem_nostop;
ALTER TEXT SEARCH CONFIGURATION french_nostop
    ALTER MAPPING FOR asciiword WITH french_stem_nostop;
ALTER TEXT SEARCH CONFIGURATION french_nostop
    ALTER MAPPING FOR hword WITH french_stem_nostop;
ALTER TEXT SEARCH CONFIGURATION french_nostop
    ALTER MAPPING FOR hword_asciipart WITH french_stem_nostop;
ALTER TEXT SEARCH CONFIGURATION french_nostop
    ALTER MAPPING FOR hword_part WITH french_stem_nostop;

SELECT to_tsvector('french_nostop', 'Amphi C'); -- 'amphi':1 'c':2

这篇关于PostGresqL全文搜索字符问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!