Skip to main content.
home | support | download

Back to List Archive

RFC - swish interface for Perl

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Wed Sep 13 2000 - 00:51:13 GMT
Hi,

I'm trying to set the interface for a Perl module to access swish and would
appreciate any comments or ideas.

The motivation for this is Jose's C library.  What I'd like to do is
develop a perl module that uses the same calls to access swish in the
standard fork/exec method, or by changing one call, access swish via the C
library.

Maybe if someone smart writes a nice threaded swish-e server this same
interface could be used.

I haven't had a lot of time to think about it, yet.  I just invented a few
methods that might be useful.  But now is a good time to gather suggestions
and make changes.  Maybe this just adds an unnecessary layer of abstraction
and confusion...


Here's the synopsis.  More can be found at
http://www.hank.org/modules/SWISH.html

NAME
    SWISH - Perl interface to the SWISH-E search engine.

SYNOPSIS
        use SWISH;
        $sh = SWISH->connect('Fork',
            prog     => '/usr/local/bin/swish-e',
            indexes  => \@indexes,
            results  => \&results,      # callback
            headers  => \&headers,
            maxhits  => 200,
            timeout  => 20,
        );

        $sh = SWISH->connect('Library', %parameters );

        $sh = SWISH->connect('Server',
            port     => $port_number,
            host     => $host_name,
            %parameters,
        );

        $hits = $sh->query(
            query       => $query_string,
            results     => \&results,
            headers     => \&headers,
            properties  => 'title subject',
            sort        => 'subject',
            startnum    => 100,
            maxhits     => 1000,
        );

        $error_msg = $sh->error unless $hits;

        # might want to use in your headers() callback
        $sh->abort_query;

        @raw_results = $sh->raw_query( \%query_settings );

        $r = $sh->index( '/path/to/config' );
        $r = $sh->index( \%indexing_settings );

        # If all config settings were stored in the index header
        $r = $sh->reindex;

        %headers = $sh->headers;
        $stemming = $sh->headers( 'stemming applied' );
        $last_indexed = $sh->headers( 'Indexed on' );

        # returns words as swish sees them for indexing
        $search_words = $sh->swish_words( \$doc );

        $stemmed = $sh->stem_word( $word );

        $sh->disconnect;
        # or an alias: 
        $sh->close;

DESCRIPTION
    This module provides a standard interface to the SWISH-E search engine.
    With this interface, your program can use SWISH-E in the standard
    forking/exec method, or with the SWISH-E C library routines, and, if
    ever developed, the SWISH-E server with only a small change.

    The idea is that you can change the way your program access SWISH-E
    without having to change your code.



Bill Moseley
mailto:moseley@hank.org
Received on Wed Sep 13 00:51:34 2000