Re: ts_count - Mailing list pgsql-hackers

From Oleg Bartunov
Subject Re: ts_count
Date
Msg-id Pine.LNX.4.64.1106050039330.9772@sn.sai.msu.ru
Whole thread Raw
In response to ts_count  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: ts_count
Re: ts_count
List pgsql-hackers
Well, there are several functions available around tsearch2. so I suggest
somebody to collect all of them and create one extension - ts_addon.
For example, these are what I remember:
1. tsvector2array
2. noccurences(tsvector, tsquery) - like your ts_count
3. nmatches(tsvector, tsquery) - # of matched lexems in query
Of course, we need to think about better names for functions, since
ts_count is a bit ambiguous.


Oleg

On Sat, 4 Jun 2011, Andrew Dunstan wrote:

>
> One of our PostgreSQL Experts Inc customers wanted a function to count all 
> the occurrences of terms in a tsquery in a tsvector. This has been written as 
> a loadable module function, and initial testing shows it is working well. 
> With the client's permission we are releasing the code - it's available at 
> <https://github.com/pgexperts/ts_count>. The actual new code involved here is 
> tiny, some of the code is C&P'd from tsrank.c and much of the rest is 
> boilerplate.
>
> A snippet from the regression test:
>
>
>   select ts_count(to_tsvector('managing managers manage peons
>   managerially'),
>                    to_tsquery('managers | peon'));
>     ts_count
>   ----------
>            4
>
> We'd like to add something like this for 9.2, so I'd like to get the API 
> agreed and then I'll prepare a patch and submit it for the next CF.
>
> Comments? cheers andrew
>
>
>
    Regards,        Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: creating CHECK constraints as NOT VALID
Next
From: Tom Lane
Date:
Subject: Re: Assert failure when rechecking an exclusion constraint