On 10/11/05, Walter Lewis <[EMAIL PROTECTED]> wrote:
> The problem:
>
> Using the perl api of Swish-e returns a reasonably relevance ranked set
> of record ids (say 150, 75, 225).  But not all of the data for the
> result set is stored in the swish indexes.
>
> If I request the records individually from the sql database afterwards,
> I end up with a significant delay (~.66 seconds per record).
>
> If I request the records collectively (e. g. WHERE ID IN (150, 75, 225))
> the results come back quickly but I don't appear to be force the order
> of these records (in the normal course of events, they arrive as 75,
> 150, 225.  Swish has the relevant order; the sql database only has the
> data.  I tried pre-loading more fields into the swish indexes but they
> are essentially flat; the data isn't.

I don't have too much time to go into a full implementation right now
and I'm not familiar with the swish-e Perl API, but assuming @recs
contains a relevance-ordered set of IDs from swish-e and you have done
the batch select using $sth = $dbh->prepare($sql) and $sth->execute()
(using your WHERE ID IN (...)) you can try:

my $sql_rows = $sth->fetchall_hashref('ID');
my @ordered_sql_rows = map { $$sql_rows{$_} } @recs;

Now @ordered_sql_rows will contain a list of hashrefs, one for each
record from the database, ordered by the swish-e relevance.

--
Mike Rylander
[EMAIL PROTECTED]
GPLS -- PINES Development
Database Developer
http://open-ils.org

Reply via email to