i'm new postgresql , working on function return word locations searched word.
i want first narrow down text fields search has go though make sure relevant result database.
my table name 'testing' text field column called 'context' , line number located called 'line_number'. context text associated specific line_number.
right ranking code looks this:
select line_number linelocation ( select testing.line_number, ts_rank_cd(to_tsvector('english', testing.context), to_tsquery('cats & dogs & kids')) score testing ) ranking score >0 order score desc; return query select * linelocation; when try print out linelocation return query, works in reporting new ranked line numbers 22,19,21,20,17,13 each returned in own column.
my problem want search each of lines (22 ... 13) key word "dog" , return position
obtaining text using:
select context sample testing testing.line_number = linelocation; if try decrement linelocation in loop linelocation -i goes out of order, , search context not relevant.
is there type of 'read next line' function use? looking way loop through ranked result line numbers
edit go on use loop want read through of rows of text in column context ranked results
the problem having reads first row of text in column 'context' , need @ of rows returned ranked search
ended creating ranking function of own, , inserting results of text search table serial increment column.
filled values of new table (ranked_results) code:
insert ranked_results(sentence) values (columnranking()); i had create function delete/reset columns in new table upon insertion of more lines.
truncate table ranked_results restart identity;
Comments
Post a Comment