/[Search-Estraier]/trunk/scripts/dbi-indexer.pl
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/scripts/dbi-indexer.pl

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

revision 194 by dpavlin, Thu Aug 31 14:43:06 2006 UTC revision 195 by dpavlin, Tue Nov 14 16:39:08 2006 UTC
# Line 15  dbi-indexer.pl - example indexer of DBI Line 15  dbi-indexer.pl - example indexer of DBI
15  =cut  =cut
16    
17  my $c = {  my $c = {
18          node_url => 'http://localhost:1978/node/dbi',          node_url => 'http://localhost:1978/node/dbi-template1',
19          dbi => 'Pg:dbname=azop',          dbi => 'Pg:dbname=template1',
20            dbuser => 'postgres',
21          sql => qq{          sql => qq{
22                  select * from history_collection_view_cache                  select * from pg_database
23          },          },
24          pk_col => '_id',          pk_col => 'datname',
25          db_encoding => 'iso-8859-2',          db_encoding => 'iso-8859-2',
26          debug => 0,          debug => 0,
27          user => 'admin',          estuser => 'admin',
28          passwd => 'admin',          estpasswd => 'admin',
29            quiet => 0,
30  };  };
31    
32  GetOptions($c, qw/node_url=s sql=s pk_col=s eb_encoding=s debug+ estuser=s estpasswd=s dbuser=s dbpasswd=s/);  GetOptions($c, qw/node_url=s dbi=s sql=s pk_col=s eb_encoding=s debug+ quiet+ estuser=s estpasswd=s dbuser=s dbpasswd=s/);
33    
34  warn "# c: ", Dumper($c) if ($c->{debug});  warn "# c: ", Dumper($c) if ($c->{debug});
35    
# Line 68  while (my $row = $sth->fetchrow_hashref( Line 70  while (my $row = $sth->fetchrow_hashref(
70                  die "can't find pk_col column '$pk_col' in results\n";                  die "can't find pk_col column '$pk_col' in results\n";
71          }          }
72    
73          printf "%4d ",$i;          my $out = '';
74            $out .= sprintf("%4d ",$i);
75    
76          while (my ($col,$val) = each %{$row}) {          while (my ($col,$val) = each %{$row}) {
77    
# Line 82  while (my $row = $sth->fetchrow_hashref( Line 85  while (my $row = $sth->fetchrow_hashref(
85                          # add body text to document (make it searchable using full-text index)                          # add body text to document (make it searchable using full-text index)
86                          $doc->add_text($val);                          $doc->add_text($val);
87    
88                          print "R";                          $out .= "R";
89                  } else {                  } else {
90                          print ".";                          $out .= ".";
91                  }                  }
92    
93          }          }
# Line 93  while (my $row = $sth->fetchrow_hashref( Line 96  while (my $row = $sth->fetchrow_hashref(
96    
97          die "error: ", $node->status,"\n" unless (eval { $node->put_doc($doc) });          die "error: ", $node->status,"\n" unless (eval { $node->put_doc($doc) });
98    
99          printf (" %d%% %.1f/s\n", int(( $i++ / $total) * 100), ( $i / (time() - $t) ) );          printf ("%s %d%% %.1f/s\n", $out, int(( $i++ / $total) * 100), ( $i / (time() - $t) ) ) unless ($c->{quiet});
100    
101  }  }

Legend:
Removed from v.194  
changed lines
  Added in v.195

  ViewVC Help
Powered by ViewVC 1.1.26