/[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

Diff of /trunk/MWS_swish.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 18 by dpavlin, Fri May 7 12:41:16 2004 UTC revision 21 by dpavlin, Sat May 8 00:54:16 2004 UTC
# Line 36  sub open_index { Line 36  sub open_index {
36  sub search_index {  sub search_index {
37          my $self = shift;          my $self = shift;
38    
39          my $s = shift || croak "search_index needs query";          croak "search_index needs query" if (! @_);
40    
41          my $index = $self->open_index;          my $index = $self->open_index;
42    
43          if ($s =~ /:/) {          my $sw;
44                  my ($fld,$val) = split(/:/,$s,2);  
45                  $s = "$fld=($val)";          foreach my $s (@_) {
46    
47                    if ($s =~ /^\s*(\w+):(.+)\s*$/) {
48                            $sw .= "$1=($2)";
49                    } else {
50                            # and/or/not operators
51                            $sw .= " $s ";
52                    }
53          }          }
54    
55          print STDERR "swish search: $s\n";          print STDERR "swish search: $sw\n";
56    
57          # convert to UTF-8          # convert to UTF-8
58          $s = $iso2utf->convert($s) || $s;          $sw = $iso2utf->convert($sw) || $sw;
59          my $results = $index->Query($s);          my $results = $index->Query($sw);
60    
61          # store total number of hits          # store total number of hits
62          $self->{'total_hits'} = $results->Hits;          $self->{'total_hits'} = $results->Hits;
# Line 71  sub search_index { Line 78  sub search_index {
78                  push @res_ids, $id;                  push @res_ids, $id;
79    
80                  foreach my $p (qw(from to cc bcc)) {                  foreach my $p (qw(from to cc bcc)) {
81                          @{$self->{cache}->{$id}->{$p}} = split(/##/, p($r,$p.'_phrase'));                          @{$self->{cache}->{$id}->{$p}} = ();
82                            foreach my $v (split(/##/, p($r,$p.'_phrase'))) {
83                                    push @{$self->{cache}->{$id}->{$p}}, $v;
84                                    $self->add_counter($p,$v);
85                            }
86                  }                  }
87    
88                  foreach my $p (qw(subject body date)) {                  foreach my $p (qw(subject body date)) {
89                          $self->{cache}->{$id}->{$p} = p($r,$p);                          $self->{cache}->{$id}->{$p} = p($r,$p);
90                  }                  }
91    
92                    $self->add_counter_calendar(p($r,'date_utime'));
93    
94                  # this is redundant, but needed for templates later...                  # this is redundant, but needed for templates later...
95                  $self->{cache}->{$id}->{'id'} = $id;                  $self->{cache}->{$id}->{'id'} = $id;
96    

Legend:
Removed from v.18  
changed lines
  Added in v.21

  ViewVC Help
Powered by ViewVC 1.1.26