/[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 14 by dpavlin, Thu May 6 19:46:58 2004 UTC revision 18 by dpavlin, Fri May 7 12:41:16 2004 UTC
# Line 46  sub search_index { Line 46  sub search_index {
46          }          }
47    
48          print STDERR "swish search: $s\n";          print STDERR "swish search: $s\n";
49    
50            # convert to UTF-8
51            $s = $iso2utf->convert($s) || $s;
52          my $results = $index->Query($s);          my $results = $index->Query($s);
53    
54            # store total number of hits
55            $self->{'total_hits'} = $results->Hits;
56    
57          my @res_ids;          my @res_ids;
58    
59            my $count = 1;
60    
61          while ( my $r = $results->NextResult ) {          while ( my $r = $results->NextResult ) {
62    
63                  sub p($$) {                  sub p($$) {
# Line 72  sub search_index { Line 80  sub search_index {
80    
81                  # this is redundant, but needed for templates later...                  # this is redundant, but needed for templates later...
82                  $self->{cache}->{$id}->{'id'} = $id;                  $self->{cache}->{$id}->{'id'} = $id;
83    
84                    last if (++$count > $self->{max_results});
85          }          }
86    
87          return @res_ids;          return @res_ids;
# Line 88  sub add_index { Line 98  sub add_index {
98          my $xml = qq{<message>};          my $xml = qq{<message>};
99          foreach my $tag (keys %$document) {          foreach my $tag (keys %$document) {
100                  my $data = $document->{$tag};                  my $data = $document->{$tag};
101                    next if (! $data || $data eq '');
102                  # save [cr/]lf before conversion to XML                  # save [cr/]lf before conversion to XML
103                  $data =~ s/\n\r/##lf##/gs;                  $data =~ s/\n\r/##lf##/gs;
104                  $data =~ s/\n/##lf##/gs;                  $data =~ s/\n/##lf##/gs;
105                  $xml .= "<$tag><![CDATA[".$data."]]></$tag>\n" if ($data && $data ne '');                  $xml .= "<$tag><![CDATA[".$data."]]></$tag>\n";
106          }          }
107          $xml .= qq{</message>};          $xml .= qq{</message>};
108    

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

  ViewVC Help
Powered by ViewVC 1.1.26