多个同义字典匹配PostgreSQL全文搜索

编程入门 行业动态 更新时间:2024-10-28 16:29:24
本文介绍了多个同义字典匹配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全文搜索

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

发布评论

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

>www.elefans.com

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