6 use Data::Dump qw/dump/;
9 my $riak_url = 'http://10.60.0.92:8098';
10 my $dbi = 'DBI:mysql:dbname=koha;host=10.60.0.10;port=3306';
16 my $dbh = DBI->connect($dbi,"","") || die $DBI::errstr;
17 my $riak = RiakSearch->new( $riak_url );
19 warn $riak->request( 'GET' => '/koha.marcxml' );
21 sub riak_search_kv_hook {
22 $riak->request( 'PUT' => shift, { props => { precommit => [ { mod => 'riak_search_kv_hook', fun => 'precommit' } ] } });
25 riak_search_kv_hook '/koha.marcxml';
27 foreach my $table ( @tables ) {
29 my $sth = $dbh->prepare(qq{ select * from $table $limit}) || die $dbh->errstr();
30 $sth->execute || die $sth->errstr();
31 my @pk = $dbh->primary_key( undef, undef, $table );
33 print "import ", $sth->rows, " rows from $table pk:",dump( @pk ),"...\n";
35 riak_search_kv_hook "koha.$table";
37 while (my $row = $sth->fetchrow_hashref() ) {
39 my $key = join('_', map { $row->{$_} } @pk);
41 if ( my $marcxml = delete $row->{marcxml} ) {
42 $riak->request( 'PUT' => "/koha.marcxml/$key", $marcxml, {
43 'Content-Type' => 'text/xml',
47 warn "# $key ",dump($row);
50 if ( exists $row->{biblionumber} && $key !~ m/biblionumber/ ) {
51 $headers->{Links} = '/koha.biblio/' . $row->{biblionumber};
53 $riak->request( 'PUT' => "/koha.$table/$key", $row, $headers );