/[webpac2]/trunk/lib/WebPAC/Search/Estraier.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/lib/WebPAC/Search/Estraier.pm

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

revision 81 by dpavlin, Mon Nov 21 14:42:22 2005 UTC revision 103 by dpavlin, Tue Nov 22 16:11:48 2005 UTC
# Line 115  sub search { Line 115  sub search {
115    
116          my $log = $self->_get_logger;          my $log = $self->_get_logger;
117    
118          $log->logconfess('need db in object') unless ($self->{'db'});          $self->confess('need db in object') unless ($self->{'db'});
119          $log->logconfess('need attr') unless ($args->{'attr'});          $self->confess('need attr') unless ($args->{'attr'});
120    
121          $log->logconfess("need attr as array not " . ref($args->{'attr'}) ) unless (ref($args->{'attr'}) eq 'ARRAY');          $self->confess("need attr as array not " . ref($args->{'attr'}) ) unless (ref($args->{'attr'}) eq 'ARRAY');
122    
123            my $q = $args->{'query'};
124    
125          my $cond = HyperEstraier::Condition->new();          my $cond = HyperEstraier::Condition->new();
126  #       $cond->add_attr("filepath ISTRINC $q");  #       $cond->add_attr("filepath ISTRINC $q");
127    
128          $cond->set_phrase( $args->{'query'} ) if ($args->{'query'});          $cond->set_phrase( $self->{'iconv'}->convert( $q ) ) if ($q);
129          $cond->set_max( $args->{'max'} ) if ($args->{'max'});          $cond->set_max( $args->{'max'} ) if ($args->{'max'});
130  #       $cond->set_options( $HyperEstraier::Condition::SURE );  #       $cond->set_options( $HyperEstraier::Condition::SURE );
131  #       $cond->set_order( 'NUMD' );  #       $cond->set_order( 'NUMD' );
# Line 132  sub search { Line 134  sub search {
134                  $log->die("can't search for ", sub { Dumper( $args ) });                  $log->die("can't search for ", sub { Dumper( $args ) });
135    
136          my $hits = $result->doc_num;          my $hits = $result->doc_num;
137          $log->debug("found $hits hits");          $log->debug("found $hits hits for '$q'");
138    
139          my @results;          my @results;
140    
141          for my $i ( 0 .. ( $hits - 1 ) ) {          for my $i ( 0 .. ( $hits - 1 ) ) {
142    
143                  $log->debug("get_doc($i)");                  #$log->debug("get_doc($i)");
144                  my $doc = $result->get_doc( $i );                  my $doc = $result->get_doc( $i );
145                  if (! $doc) {                  if (! $doc) {
146                          $log->warn("can't find result $i");                          $log->warn("can't find result $i");
# Line 149  sub search { Line 151  sub search {
151    
152                  foreach my $attr (@{ $args->{'attr'} }) {                  foreach my $attr (@{ $args->{'attr'} }) {
153                          my $val = $doc->attr( $attr );                          my $val = $doc->attr( $attr );
154                          $log->debug("attr $attr = ", $val || 'undef');                          #$log->debug("attr $attr = ", $val || 'undef');
155                          $hash->{$attr} = $self->{'iconv'}->convert( $val ) if (defined($val));                          $hash->{$attr} = $self->{'iconv'}->convert( $val ) if (defined($val));
156                  }                  }
157    
# Line 159  sub search { Line 161  sub search {
161    
162          }          }
163    
164          $log->debug("results " . Dumper( \@results ));  #       $log->debug("results " . Dumper( \@results ));
165    
166          $log->logconfess("expected to return array") unless (wantarray);          $self->confess("expected to return array") unless (wantarray);
167    
168          return @results;          return @results;
169  }  }
# Line 177  C<die>. Line 179  C<die>.
179  sub confess {  sub confess {
180          my $self = shift;          my $self = shift;
181          if (my $log = $self->{'log'}) {          if (my $log = $self->{'log'}) {
182                  if ($log->can('confess')) {                  if ($log->can('logconfess')) {
183                          $log->confess(@_);                          $log->logconfess(@_);
184                  } elsif ($log->can('fatal')) {                  } elsif ($log->can('fatal')) {
185                          $log->fatal(@_);                          $log->fatal(@_);
186                            die @_;
187                  } elsif ($log->can('error')) {                  } elsif ($log->can('error')) {
188                          $log->error(@_);                          $log->error(@_);
189                  } else {                  } else {

Legend:
Removed from v.81  
changed lines
  Added in v.103

  ViewVC Help
Powered by ViewVC 1.1.26