|
Lines 9-15
Index Koha records by chunks. It is useful when a record causes errors and
Link Here
|
| 9 |
stops the indexing process. With this script, if indexing of one chunk fails, |
9 |
stops the indexing process. With this script, if indexing of one chunk fails, |
| 10 |
that chunk is split into two or more chunks, and indexing continues on these chunks. |
10 |
that chunk is split into two or more chunks, and indexing continues on these chunks. |
| 11 |
rebuild_zebra.pl is called only once to export records. Splitting and indexing |
11 |
rebuild_zebra.pl is called only once to export records. Splitting and indexing |
| 12 |
is handled by this script (using yaz-marcdump and zebraidx). |
12 |
is handled by this script (using zebraidx for indexing). |
| 13 |
|
13 |
|
| 14 |
Usage: |
14 |
Usage: |
| 15 |
$scriptname [-t type] [-l X] [-o X] [-s X] [-d /export/dir] [-L /log/dir] [-r] [-f] [--reset-index] |
15 |
$scriptname [-t type] [-l X] [-o X] [-s X] [-d /export/dir] [-L /log/dir] [-r] [-f] [--reset-index] |
|
Lines 41-46
splitfile() {
Link Here
|
| 41 |
local prefix=$2 |
41 |
local prefix=$2 |
| 42 |
local size=$3 |
42 |
local size=$3 |
| 43 |
local script=' |
43 |
local script=' |
|
|
44 |
my $indexmode = '"$INDEXMODE"'; |
| 44 |
my $prefix = '"\"$prefix\""'; |
45 |
my $prefix = '"\"$prefix\""'; |
| 45 |
my $size = '"$size"'; |
46 |
my $size = '"$size"'; |
| 46 |
my ($i,$count) = (0,0); |
47 |
my ($i,$count) = (0,0); |
|
Lines 52-61
splitfile() {
Link Here
|
| 52 |
if ($closed) { |
53 |
if ($closed) { |
| 53 |
open($out, ">", sprintf("$prefix%02d", $i)); |
54 |
open($out, ">", sprintf("$prefix%02d", $i)); |
| 54 |
$closed = 0; |
55 |
$closed = 0; |
|
|
56 |
if ($indexmode == "dom" && $line !~ /<collection>/) { |
| 57 |
print $out "<collection>"; |
| 58 |
} |
| 55 |
} |
59 |
} |
| 56 |
print $out $line; |
60 |
print $out $line; |
| 57 |
$count++ if ($line =~ m|^</record>|); |
61 |
$count++ if ($line =~ m|^</record>|); |
| 58 |
if ($count == $size) { |
62 |
if ($count == $size) { |
|
|
63 |
if ($indexmode == "dom" && $line !~ m|</collection>|) { |
| 64 |
print $out "</collection>"; |
| 65 |
} |
| 59 |
$count = 0; |
66 |
$count = 0; |
| 60 |
$i++; |
67 |
$i++; |
| 61 |
close($out); |
68 |
close($out); |
|
Lines 88-94
indexfile() {
Link Here
|
| 88 |
$ZEBRAIDX_CMD >$logfile 2>&1 |
95 |
$ZEBRAIDX_CMD >$logfile 2>&1 |
| 89 |
grep "Records: $size" $logfile >/dev/null 2>&1 |
96 |
grep "Records: $size" $logfile >/dev/null 2>&1 |
| 90 |
if [ $? -ne 0 ]; then |
97 |
if [ $? -ne 0 ]; then |
| 91 |
echo "Indexing failed. Split file and continue..." |
98 |
echo "Indexing failed. See log file $logfile" |
|
|
99 |
echo "Split file and continue..." |
| 92 |
indexfile $chunkfile $(($chunkssize/2)) |
100 |
indexfile $chunkfile $(($chunkssize/2)) |
| 93 |
else |
101 |
else |
| 94 |
ZEBRAIDX_CMD="$ZEBRAIDX -c $CONFIGFILE -d $TYPE -g marcxml commit" |
102 |
ZEBRAIDX_CMD="$ZEBRAIDX -c $CONFIGFILE -d $TYPE -g marcxml commit" |
|
Lines 274-289
EXPORTFILE=
Link Here
|
| 274 |
case $TYPE in |
282 |
case $TYPE in |
| 275 |
biblios ) |
283 |
biblios ) |
| 276 |
EXPORTFILE="$EXPORTDIR/biblio/exported_records" |
284 |
EXPORTFILE="$EXPORTDIR/biblio/exported_records" |
|
|
285 |
indexmode_config_name="zebra_bib_index_mode" |
| 277 |
;; |
286 |
;; |
| 278 |
authorities ) |
287 |
authorities ) |
| 279 |
EXPORTFILE="$EXPORTDIR/authority/exported_records" |
288 |
EXPORTFILE="$EXPORTDIR/authority/exported_records" |
|
|
289 |
indexmode_config_name="zebra_auth_index_mode" |
| 280 |
;; |
290 |
;; |
| 281 |
* ) |
291 |
* ) |
| 282 |
echo "Error: TYPE '$TYPE' is not supported" |
292 |
echo "Error: TYPE '$TYPE' is not supported" |
| 283 |
exit 1 |
293 |
exit 1 |
| 284 |
esac |
294 |
esac |
| 285 |
|
295 |
|
| 286 |
CONFIGFILE="$(dirname $KOHA_CONF)/zebradb/zebra-$TYPE.cfg" |
296 |
INDEXMODE=$(perl -e ' |
|
|
297 |
use C4::Context; |
| 298 |
print C4::Context->config('"$indexmode_config_name"'); |
| 299 |
') |
| 300 |
|
| 301 |
CONFIGFILE=$(perl -e ' |
| 302 |
use C4::Context; |
| 303 |
my $zebra_server = ('"$TYPE"' eq "biblios") ? "biblioserver" : "authorityserver"; |
| 304 |
print C4::Context->zebraconfig($zebra_server)->{config}; |
| 305 |
') |
| 287 |
|
306 |
|
| 288 |
if [ $RESETINDEX = "yes" ]; then |
307 |
if [ $RESETINDEX = "yes" ]; then |
| 289 |
RESETINDEX_CMD="$ZEBRAIDX -c $CONFIGFILE init" |
308 |
RESETINDEX_CMD="$ZEBRAIDX -c $CONFIGFILE init" |
| 290 |
- |
|
|