2009-03-19

Text search setup for several languages

There are several ways - below is one common setup.

Assuming you know language, text search setup can be easy. Below is an example for english-russian text collection.

postgres=# create table inttext ( lang regconfig, doc text);
CREATE TABLE
Time: 760.216 ms
postgres=# insert into inttext values('russian','голубые дали');
INSERT 0 1
Time: 365.939 ms
postgres=# insert into inttext values('english','hazy distance');
INSERT 0 1
Time: 363.096 ms
postgres=# select to_tsvector(lang,doc) from inttext;
     to_tsvector
----------------------
 'голуб':1 'дал':2
 'distanc':2 'hazi':1
(2 rows)

Of course, instead of built-in text search configurations you can use your very own.

Another alternatives are: