多个同义字典匹配PostgreSQL全文搜索 [英] Multiple synonym dictionary matches in PostgreSQL full text searching

查看:278
本文介绍了多个同义字典匹配PostgreSQL全文搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在PostgreSQL 8.3中进行全文搜索。它工作出色,所以我添加同义词匹配(例如'bob'=='robert')使用同义字典。那也很好。但是我注意到,它显然只允许一个单词具有一个同义词。也就是说,'al'不能是'albert'和'allen'。

I am trying to do full text searching in PostgreSQL 8.3. It worked splendidly, so I added in synonym matching (e.g. 'bob' == 'robert') using a synonym dictionary. That works great too. But I've noticed that it apparently only allows a word to have one synonym. That is, 'al' cannot be 'albert' and 'allen'.

这是正确的吗?有没有办法在PostgreSQL同义词字典中有多个字典匹配?

Is this correct? Is there any way to have multiple dictionary matches in a PostgreSQL synonym dictionary?

为了参考,这里是我的示例字典文件:

For reference, here is my sample dictionary file:

bob    robert
bobby  robert
al     alan
al     albert
al     allen

创建全文搜索配置的SQL:

And the SQL that creates the full text search config:

CREATE TEXT SEARCH DICTIONARY nickname (TEMPLATE = synonym, SYNONYMS = nickname);
CREATE TEXT SEARCH CONFIGURATION dxp_name (COPY = simple);
ALTER TEXT SEARCH CONFIGURATION dxp_name ALTER MAPPING FOR asciiword WITH nickname, simple;

我做错了什么?谢谢!

推荐答案

这是同义词工作的一个限制。你可以做的是如下:

That's a limitation in how the synonyms work. What you can do is turn it around as in:

bob    robert
bobby  robert
alan   al
albert al
allen  al

应该给出相同的最终结果,这是搜索其中一个将匹配相同的东西。

It should give the same end result, which is that a search for either one of those will match the same thing.

这篇关于多个同义字典匹配PostgreSQL全文搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆