184 |
my $t = time(); |
my $t = time(); |
185 |
my $pk = $c->{pk} || 'id'; |
my $pk = $c->{pk} || 'id'; |
186 |
|
|
187 |
|
warn "indexing existing ",$sth->rows," rows\n"; |
188 |
|
|
189 |
while (my $row = $sth->fetchrow_hashref() ) { |
while (my $row = $sth->fetchrow_hashref() ) { |
190 |
|
|
191 |
warn "# row: ",Dumper($row) if ($c->{debug} >= 3); |
warn "# row: ",Dumper($row) if ($c->{debug} >= 3); |
199 |
die "can't find pk column '$pk' in results\n"; |
die "can't find pk column '$pk' in results\n"; |
200 |
} |
} |
201 |
|
|
202 |
printf "%4d ",$i; |
my $log = sprintf "%4d ",$i; |
203 |
|
|
204 |
while (my ($col,$val) = each %{$row}) { |
while (my ($col,$val) = each %{$row}) { |
205 |
|
|
210 |
# add body text to document (make it searchable using full-text index) |
# add body text to document (make it searchable using full-text index) |
211 |
$doc->add_text($val); |
$doc->add_text($val); |
212 |
|
|
213 |
print "R"; |
$log .= "R"; |
214 |
} else { |
} else { |
215 |
print "."; |
$log .= "."; |
216 |
} |
} |
217 |
|
|
218 |
} |
} |
221 |
|
|
222 |
die "error: ", $node->status,"\n" unless (eval { $node->put_doc($doc) }); |
die "error: ", $node->status,"\n" unless (eval { $node->put_doc($doc) }); |
223 |
|
|
224 |
printf (" %d%% %.1f/s\n", int(( $i++ / $total) * 100), ( $i / (time() - $t) ) ); |
$log .= sprintf(" %d%% %.1f/s\r", int(( $i++ / $total) * 100), ( $i / (time() - $t) ) ); |
225 |
|
|
226 |
|
print STDERR $log; |
227 |
|
|
228 |
} |
} |
229 |
|
|
255 |
my $col_def = join(', ', map { "$_ text" } @cols); |
my $col_def = join(', ', map { "$_ text" } @cols); |
256 |
|
|
257 |
print " |
print " |
258 |
## example SQL search query: |
-- example SQL search query: |
259 |
|
|
260 |
SELECT $col_names |
SELECT $col_names |
261 |
FROM pgest( |
FROM pgest( |