Skip to main content.
home | support | download

Back to List Archive

Re: RFC - swish interface for Perl

From: Bas Meijer <bas(at)>
Date: Fri Sep 15 2000 - 09:31:31 GMT
At 21:02 -0700 13-09-2000, Bill Moseley wrote:
>At 01:30 AM 09/13/00 -0700, you wrote:
>>Looking through your synopsis a thought rised: would it be possible
>>to think of swish as a database, I mean could it be accessible
>>through a DBI interface?
>Hi Bas,
>I thought about building a database driver for DBI, but I didn't really
>feel like it fit into DBI that well.  Plus, it looks like more work,
>considering I have no experience in writing a DBI driver.  But I don't
>really see any reason why not.  I'll take a look at the DBI::DBD faq and
>see what I can come up with.

The definite guide to DBI is: Programming the Perl DBI, 2000, 
Alligator Descartes & Tim Bunce. Published by O' Reilly isbn 

>   $dbh = DBI->connect( 'DBI:swish:myindex',$dbuser, $dbpassword, \%attr);
>For the DSN what do you think?
>   DBI:ForkSwish:index.swish-e
>   DBI:LibSwish:non-stemmed
>   DBI:ServerSwish:myindex
>   DBI:OpenSwish:  <-- how to deal with non-forking platforms in a safe way?

If you plan different drivers for each access method that could be.
If you would write one 'do-it-all' DBI driver for swish i would expect:

>Should one be able to change index files from prepare() to prepare() with
>the same $dbh?  I'd say no.

I agree.

>Maybe the DSN should be DBI::ForkSwish and specify the index file(s) in
>%attr.  That is maybe one of these:
>   $dbh = DBI->connect( 'DBI:ForkSwish:indexes=index1,index2',$u, $p );
>   $dbh = DBI->connect( 'DBI:ForkSwish:',$u, $p, { indexes => \@indexes} );
>The second is my favorite.

Some ideas to consider for the DSN:
"most drivers expect either a simple database name or, more often, a 
set of one or more name/value pairs separated with semicolons."
"the DBD::CSV module treats a group of ... files in a common 
directory as a database"

>Then the prepare:
>   $sth = $dbh->prepare("-w $query -m $results $tflag $search_tags");
>Well, I doubt we need SQL for the prepare.  But I would rather pass a hash
>reference or object attributes as I'd rather not have to try and parse the
>query string.  I guess I could also do something like my previous example:
>   $dbh->query( 'subject=(apples or oranges)' );
>   $sth = $dbh->prepare({ query => $query, %parameters});

I think the point of prepare() in swish context is that there's a 
check on passing a valid query. SQL might be overkill, but we do need 
a way to handle the different query types to swish: the boolean 
operators, phrases, document partflags, dates, pagination parameters

>then fetchrow() would do the real work.
>Anyway, thanks very much for the comments.  Any other suggestions or ideas
>are more than welcome.
>Bill Moseley


--  /'''     Bas Meijer
     c-OO Web Services
     \  >     Kerkstraat 19 Postbus 256 1400 AG Bussum
      \&&     t. +31 35 7502100  f. +31 35 7502111
Received on Fri Sep 15 09:31:59 2000