/[mws]/trunk/MWS_swish.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/MWS_swish.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (hide annotations)
Thu May 6 12:40:11 2004 UTC (20 years ago) by dpavlin
File size: 1056 byte(s)
switch search engine to swish-e. It's stil slow, but usable.

1 dpavlin 12 #!/usr/bin/perl -w
2    
3     use strict;
4    
5     #
6     # simple implementation to use SWISH-e with queryies like
7     # Lucene (subject:something)
8     #
9    
10     use SWISH::API;
11    
12     sub open_index {
13     my $self = shift;
14    
15     my $swish = $self->{index};
16    
17     if (! $swish) {
18    
19     my $index_file = $self->{index_file} || croak "open_index needs index filename";
20     $index_file .= "/swish-e";
21     print STDERR "opening index '$index_file'\n";
22     $swish = SWISH::API->new($index_file);
23     $swish->AbortLastError if $swish->Error;
24    
25     $self->{index} = $swish;
26     }
27    
28     return $swish;
29     }
30    
31     sub search_index {
32     my $self = shift;
33    
34     my $s = shift || croak "search_index needs query";
35    
36     my $index = $self->open_index;
37    
38     if ($s =~ /:/) {
39     my ($fld,$val) = split(/:/,$s,2);
40     $s = "$fld=($val)";
41     }
42    
43     print STDERR "swish search: $s\n";
44     my $results = $index->Query($s);
45    
46     my @r;
47    
48     while ( my $result = $results->NextResult ) {
49     push @r, $result->Property( "swishdocpath" );
50     }
51    
52     return @r;
53     }
54    
55     sub add_index {
56     my $self = shift;
57    
58     croak("add_index is not implemented for swish!");
59     }
60    
61     sub close_index {
62     my $self = shift;
63    
64     }
65    
66     1;

  ViewVC Help
Powered by ViewVC 1.1.26