Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple synonym dictionary matches in full-text searching

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.

However, I've noticed that it apparently only allows a word to have one synonym. That is, al cannot be albert or allen.

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

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;
like image 577
Ryan VanMiddlesworth Avatar asked Jul 30 '09 19:07

Ryan VanMiddlesworth


People also ask

What is the synonym for the word some?

Synonyms: any , a few, several , a number, an amount, a certain amount, a part, a portion, a good few, a fair few. Sense: Adjective: few. Synonyms: a few, a little , a bit, part of, more than a few, more than a little, any , several , various.

What is the antonym of multiple?

Opposite of used or performed by a number of people as a group. exclusive. individual. single. singular.


1 Answers

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.

like image 161
Magnus Hagander Avatar answered Oct 20 '22 20:10

Magnus Hagander