GetCovers

GetCovers - see what did you find

Function get_covers(tsvector,query) marks extents (from tsvector ), which satisfies the search query (extents could overlap). The markup is as follow: {# text }#, where # - is the extent number. This function is useful for debugging.

Example:

test=# select get_covers(to_tsvector('1 2 3 4 5 6 1 3 1 9 34 2'),'1&3');
                    get_covers
---------------------------------------------------
 {1 1 2 {2 3 }1 4 5 6 {3 1 }2 {4 3 }3 1 }4 9 34 2
(1 row)

For long document the output could be crappy and analysis could be very complicated. So, we could use:

test=# select get_covers(to_tsvector('1 2 3 4 5 6 1 3 1 9 34 2'),'2&34',2);
              get_covers
---------------------------------------
 1 {1#2 2 3 4 ... {2#11 34 }1#12 2 }2#13
(1 row)

Here, 1#2 denotes 1st extent begins from 2nd position, … - hidden words, controlled by the 3rd parameter (how many words we leave in extent from the beginning). First example could be obtained using get_covers(fts,query,0).