Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 216A513364DE for ; Mon, 24 Jan 2011 06:14:23 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 29969-10 for ; Mon, 24 Jan 2011 10:14:15 +0000 (UTC) X-Greylist: delayed 00:05:21.197269 by SQLgrey-1.7.6 Received: from smtp207.alice.it (smtp207.alice.it [82.57.200.103]) by mail.postgresql.org (Postfix) with ESMTP id 43E221337B77 for ; Mon, 24 Jan 2011 06:14:15 -0400 (AST) Received: from lan.webthatworks.it (82.50.78.201) by smtp207.alice.it (8.5.124.08) id 4C9E16C909C90282; Mon, 24 Jan 2011 11:08:49 +0100 Received: from dawn.webthatworks.it (dawn.webthatworks.it [192.168.1.12]) by lan.webthatworks.it (Postfix) with ESMTP id 9D87E30024C; Mon, 24 Jan 2011 11:08:48 +0100 (CET) Received: from dawn.webthatworks.it (localhost [127.0.0.1]) by dawn.webthatworks.it (Postfix) with ESMTP id 6022F3DFBD; Mon, 24 Jan 2011 11:08:48 +0100 (CET) Date: Mon, 24 Jan 2011 11:08:47 +0100 From: Ivan Sergio Borgonovo To: pgsql-sql@postgresql.org Cc: Subject: Re: Postgres function for full text search Message-ID: <20110124110847.3bef4f9e@dawn.webthatworks.it> In-Reply-To: References: Organization: http://www.webthatworks.it X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201101/71 X-Sequence-Number: 35018 On Mon, 24 Jan 2011 10:38:02 +0100 - 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