4 # ./reindex.pl user=admin,password=SWORDFISH,localhost:8018/IR-Explain---1
5 # ./reindex.pl -d -q zeerex.reliability=0 localhost:8018/IR-Explain---1
15 my $query = 'cql.allRecords=1';
19 'noAction' => \$noAction,
22 print STDERR "Usage: $0 [-s|--setUdb] [-d|--delete] [-n|--noaction] [-q <query>] <target>\n";
26 my $conn = new ZOOM::Connection($ARGV[0]);
27 $conn->option(preferredRecordSyntax => "xml");
28 $conn->option(elementSetName => "zebra::data");
29 my $rs = $conn->search(new ZOOM::Query::CQL($query));
33 print "$0: reindexing $n records\n";
34 foreach my $i (1..$n) {
36 print " $i/$n (", int($i*100/$n), "%)\n" if $i % 50 == 0;
37 my $rec = $rs->record($i-1);
38 my $xml = $rec->render();
39 if ($xml !~ /<\/(e:)?host>/) {
40 # There is an undeletable phantom record: ignore it
45 my $udb = qq[<i:udb xmlns:i="http://indexdata.com/irspy/1.0">irspy-$i</i:udb>];
46 $xml =~ s/<\/(e:)?host>/$1$udb/;
51 print " $n/$n (100%)\n" if $n % 50 != 0;
56 # These might be better as ZOOM::Connection methods
61 my $p = $conn->package();
62 $p->option(action => $delete ? "recordDelete" : "specialUpdate");
63 $p->option(record => $xml);
71 my $p = $conn->package();