Re: Postgres function for full text search

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-sql(at)postgresql(dot)org
Cc: <grandebuzon(at)gmail(dot)com>
Subject: Re: Postgres function for full text search
Date: 2011-01-24 10:08:47
Message-ID: 20110124110847.3bef4f9e@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 24 Jan 2011 10:38:02 +0100
- <grandebuzon(at)gmail(dot)com> wrote:

> Hello everyone.
> My question if any known one postgres function, for full text
> search that separates words with "| "?
> As plainto_tsquery separating words with "& ".
>
> For example text "word1 word2 word3 word4"
> and conversion rates for full text search postgres "word1 | word2
> | word3 | word4"

I wrote a C extension that could help...

Currently there are
CREATE OR REPLACE FUNCTION tsvector_to_table(
IN tsv tsvector,
OUT lexeme text,
OUT weight smallint[],
OUT pos int[])

CREATE OR REPLACE FUNCTION tsvector_to_tsquery(
IN tsv tsvector,
op IN char(1),
weights IN varchar(4),
maxpos IN smallint )
RETURNS tsquery

op is | or &
It will ignore elements in the tsvector whose position is >maxpos.
It will ignore elements whose weight is not in weights

So it could turn
gino:1,3,5A pino:2B into
gino:A | pino:B

The code has been working in production by several months but:
- it is for 8.3 (there are some notes to port it to >8.4, namely
supporting prefixes)
- I wrote it for my environment so the "build" script are simple but
you'll have to adjust them to your environment.

The code could be released in GPL or FreeBSD license.
I'd be happy if someone could guide me in the process of
successfully donating this code to the community.

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message manuel antonio ochoa 2011-01-25 00:18:32 check files .backup
Previous Message Piotr Czekalski 2011-01-24 09:51:28 Re: loosing data in postgres database