1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use strict; |
use strict; |
4 |
use Search::Estraier; |
use Search::Estraier 0.06; |
5 |
use URI::Escape qw/uri_escape/; |
use URI::Escape qw/uri_escape/; |
6 |
use Time::HiRes; |
use Time::HiRes; |
7 |
use POSIX qw/strftime/; |
use POSIX qw/strftime/; |
19 |
my $debug = 0; |
my $debug = 0; |
20 |
my $max = 256; |
my $max = 256; |
21 |
|
|
|
$max = 1024; |
|
|
|
|
22 |
# create and configure node |
# create and configure node |
23 |
my $from_n = new Search::Estraier::Node( |
my $from_n = new Search::Estraier::Node( |
24 |
url => $from, |
url => $from, |
25 |
croak_on_error => 1, |
croak_on_error => 1, |
26 |
debug => $debug, |
debug => $debug, |
27 |
|
user => 'admin', |
28 |
|
passwd => 'admin', |
29 |
); |
); |
30 |
my $to_n = new Search::Estraier::Node( |
my $to_n = new Search::Estraier::Node( |
31 |
url => $to, |
url => $to, |
32 |
croak_on_error => 1, |
croak_on_error => 1, |
33 |
debug => $debug, |
debug => $debug, |
34 |
|
user => 'admin', |
35 |
|
passwd => 'admin', |
36 |
|
create => 1, |
37 |
|
label => $from_n->label, |
38 |
); |
); |
39 |
|
|
40 |
print "Copy from ",$from_n->name," (",$from_n->label,") to ",$to_n->name," (",$to_n->label,") - ",$from_n->doc_num," documents (",$from_n->word_num," words, ",$from_n->size," bytes)\n"; |
print "Copy from ",$from_n->name," (",$from_n->label,") to ",$to_n->name," (",$to_n->label,") - ",$from_n->doc_num," documents (",$from_n->word_num," words, ",$from_n->size," bytes)\n"; |
60 |
} |
} |
61 |
foreach my $l (split(/\n/,$res)) { |
foreach my $l (split(/\n/,$res)) { |
62 |
(my $id, $prev) = split(/\t/,$l, 2); |
(my $id, $prev) = split(/\t/,$l, 2); |
63 |
$to_n->put_doc( $from_n->get_doc( $id )); |
|
64 |
|
#$to_n->put_doc( $from_n->get_doc( $id )); |
65 |
|
|
66 |
|
my $doc_draft = $from_n->_fetch_doc( id => $id, chomp_resbody => 1 ); |
67 |
|
$to_n->shuttle_url( $to_n->{url} . '/put_doc', 'text/x-estraier-draft', $doc_draft, undef) == 200 or die "can't insert $doc_draft\n"; |
68 |
|
|
69 |
$i++; |
$i++; |
70 |
} |
} |
71 |
warn "$prev\n"; |
warn "$prev\n" if ($debug); |
72 |
|
|
73 |
my $rate = ( $i / (time() - $t) ); |
my $rate = ( $i / (time() - $t) ); |
74 |
printf("%d records, %1.2f%% [%1.2f rec/s] estimated finish: %s\n", |
printf("%d records, %1.2f%% [%1.2f rec/s] estimated finish: %s\n", |