For an extension I am writing, I want to be able to write a function
that does this:
select * from table where field = textsearch(field, 'la bla bla', 10)
order by score(10);
I can currently do this:
create temp table search_results (key int, rank int);
select plpgsql_textsearch(....);
select * from table where field = search_results.key order by rank;
drop table search_results;
The plpgsql function calls textsearch and populates the table doing
inserts. As:
for pos in 0 .. count-1 loop
insert into search_result(key, rank)
values (search_key(handle,pos),
search_rank(handle,pos));
end loop;
Obviously, if I return a field type I force a table scan, if I return a
set of tuples postgres should be able to perform a join.
From what I can see, it looks like I need to create a heap tuple, and
add tuples to it. Is this correct? It is also unclear how I should go
about this. Does anyone have any code that does this already?
If this is the wrong forum in which to ask this question, I apologize,
but I just can't see any clear way to do this.
--
http://www.mohawksoft.com