Skip site navigation (1) Skip section navigation (2)

Boolean text, with phrase ranking, search under Postgres

From: markw <markw(at)mohawksoft(dot)com>
To: pgsql-announce(at)postgresql(dot)org(dot)pgsql-general(at)postgresql(dot)org
Subject: Boolean text, with phrase ranking, search under Postgres
Date: 2000-10-16 18:32:38
Message-ID: 39EB49C6.225A89E9@mohawksoft.com (view raw or flat)
Thread:
Lists: pgsql-announcepgsql-general
I am working on a GPL version of a boolean text search engine for
PostgreSQL.

How it works:

You run a program which executes a query and builds a set of external
indexes.

Then you run a daemon process which does the processing of the text
query.

In postgres, you create a temporary table of results, call textsearch
which populates the table,
lastly, you join with the results table. The code looks like this:

>>>>>>>>>>>>>
--
-- Create a temporary table for search results
--
create temp table search_result (key integer, rank integer);
--
-- Call search daemon to populate table
--
select textsearch('performer2{ waitresses } song { i know what boys like
}');
--
-- Join result table with data tables
--
select title, song, performer2, rank from zsong, ztitles, search_result
        where search_result.key = zsong.trackid and
        zsong.muzenbr = ztitles.muzenbr
        order by search_result.rank desc;
--
-- Finished with result table, drop it.
--
drop table search_result ;
<<<<<<<<<<<<<<<<

he textsearch function looks like:
>>>>>>>>>>>>>>>>>>>>>>>>
create function textsearch(varchar) returns integer as
        '
        DECLARE
                handle  integer;
                count   integer;
                pos     integer;
        BEGIN
                handle = search_exec( \'localhost\', $1);

                count = search_count(handle);

                for pos in 0 .. count-1 loop
                        insert into search_result(key, rank)
                        values (search_key(handle,pos),
search_rank(handle,pos));
                end loop;

                return search_done(handle);

        END;
' language 'plpgsql';


What I would like to do is create the result table in the function
and/or accept a table name as a parameter. I can't seem to do this,
perhaps I am missing something trivial.

Is there a way to create a table from within 'c' and return it?  I am
not a postgres pro, I am a C/C++ guy and do not know the ins and outs of
Postgres, and it should be a lot easier to make something more eficient.
Any insign would be appreciated.




Responses

pgsql-announce by date

Next:From: Edmar WiggersDate: 2000-10-17 00:06:42
Subject: C function returning rows, was Boolean text, with phrase ranking, search under Postgres
Previous:From: Joerg HessdoerferDate: 2000-10-16 16:12:38
Subject: Re: New PostgreSQL binary distro for Windows NT

pgsql-general by date

Next:From: Bruce MomjianDate: 2000-10-16 18:36:45
Subject: Re: [GENERAL] PL/Perl compilation error
Previous:From: Joseph ShraibmanDate: 2000-10-16 17:59:15
Subject: Re: Error building JDBC Driver

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group