Yoann Moreau <yoann.moreau@univ-avignon.fr> wrote:
> I'd need a function like this :
> select term_positions(text, 'get') from docs;
> id_doc | positions
> --------+-----------
> 1 | {2,6}
> 2 | {3}
>
> I'd like to add this function in my database, for experimental
> purpose. I got a look at the source code but didn't find some code
> example using the GIN index ;
> I can not figure out where the GIN index is read as a tsvector
> or where the '@@' operator gets the matching tsvectors for the
> terms of the tsquery.
>
> Any help about where to start reading would be very welcome :)
I'm not really clear on what you want to read about. Do you need
help creating your own function on the fly, or with how to access
the information to write the function?
If the former, these links might help:
http://www.postgresql.org/docs/9.1/interactive/extend.html
http://www.postgresql.org/docs/9.1/interactive/sql-createfunction.html
If the latter, have you looked at this file?:
src/backend/utils/adt/tsrank.c
Or was it something else that I'm missing?
-Kevin