tsearch2: How to use different configurations for two columns? - Mailing list pgsql-general

From Stephan Vollmer
Subject tsearch2: How to use different configurations for two columns?
Date
Msg-id 43999B6D.4020500@gmx.de
Whole thread Raw
Responses Re: tsearch2: How to use different configurations for two columns?
List pgsql-general
Hi all,

is it possible to index 2 columns in a table with tsearch2 using
different configurations for each column index?

I have a table publications that is defined as follows (simplified):

CREATE TABLE publications
(
  title           text,
  author_list     text,
  fti_title       tsvector,
  fti_author_list tsvector,
)
WITHOUT OIDS;

CREATE INDEX idx_fti_author_list ON publications
  USING gist (fti_author_list);

CREATE INDEX idx_fti_title ON publications
  USING gist (fti_title);

CREATE TRIGGER tsvectorupdate_title
  BEFORE INSERT OR UPDATE ON publications
  FOR EACH ROW
  EXECUTE PROCEDURE tsearch2('fti_title', 'title');

CREATE TRIGGER tsvectorupdate_author_list
  BEFORE INSERT OR UPDATE ON publications
  FOR EACH ROW
  EXECUTE PROCEDURE tsearch2('fti_author_list', 'author_list');

The column 'author_list' contains names of authors with many
abbreviated first names, e. g. "S. Vollmer  Michael F. Smith". These
abbreviated first names "S." and "F." shouldn't be indexed. To do
this, I created a tsearch2 configuration 'authors' that uses a
stopword list with "a...z" as stopwords.

The configuration seems to work fine, but I can't get tsearch2 to
use the 'author' config for column 'author_list' and 'default'
config for column 'title'. Is there any way to accomplish this?


If the solution is not possible or too complicated, as a workaround
I could use a function that deletes the abbreviated first names
before the column is indexed - similar to the function
"dropatsymbol()" mentioned in the tsearch2 documentation. I tried to
use replace(), but I'd need a function with regexps.

Thanks in advance,

- Stephan

Attachment

pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: pg_dump problems
Next
From: "Andrew J. Kopciuch"
Date:
Subject: Re: tsearch2: How to use different configurations for two columns?