use RiakSearch;
use Data::Dump qw/dump/;
-my $limit = "limit 5";
-my $riak_url = 'http://10.60.0.92:8098';
-my $dbi = 'DBI:mysql:dbname=koha;host=10.60.0.10;port=3306';
+
+my ( $riak_url, $dbi ) = @ARGV;
+
+$riak_url ||= 'http://10.60.0.92:8098';
+$dbi ||= 'DBI:mysql:dbname=koha;host=10.60.0.10;port=3306';
my @tables = qw(
biblioitems
biblio
);
+my $limit;
+$limit = $ENV{LIMIT} if $ENV{LIMIT};
+
my $dbh = DBI->connect($dbi,"","") || die $DBI::errstr;
my $riak = RiakSearch->new( $riak_url );
warn $riak->request( 'GET' => '/koha.marcxml' );
sub riak_search_kv_hook {
- $riak->request( 'PUT' => shift, { props => { precommit => [ { mod => 'riak_search_kv_hook', fun => 'precommit' } ] } });
+ $riak->request( 'PUT' => shift, { props => {
+ precommit => [ { mod => 'riak_search_kv_hook', fun => 'precommit' } ],
+# precommit => [],
+# last_write_wins => 'true',
+ }
+ });
}
-riak_search_kv_hook '/koha.marcxml';
+riak_search_kv_hook 'koha.marcxml';
foreach my $table ( @tables ) {
while (my $row = $sth->fetchrow_hashref() ) {
my $key = join('_', map { $row->{$_} } @pk);
+ my $biblionumber = $row->{biblionumber};
if ( my $marcxml = delete $row->{marcxml} ) {
$riak->request( 'PUT' => "/koha.marcxml/$key", $marcxml, {
'Content-Type' => 'text/xml',
+ 'Link' => qq|</riak/koha.$table/$biblionumber>; riaktag="biblio"|,
} );
}
- warn "# $key ",dump($row);
+# warn "## $key ",dump($row);
my $headers;
- if ( exists $row->{biblionumber} && $key !~ m/biblionumber/ ) {
- $headers->{Links} = '/koha.biblio/' . $row->{biblionumber};
- }
+ $headers->{Link} = qq|</riak/koha.biblio/$biblionumber>; riaktag="biblio"|
+ if $biblionumber && $key !~ m/biblionumber/;
+
$riak->request( 'PUT' => "/koha.$table/$key", $row, $headers );
}