Bug 21908: Add DISTINCT biblionumber to rebuild_zebra.pl
[koha.git] / misc / migration_tools / rebuild_zebra.pl
index c3f41df..c193d62 100755 (executable)
@@ -144,7 +144,7 @@ if (not $biblios and not $authorities) {
     die $msg;
 }
 
-our @tables_allowed_for_select = ( 'biblioitems', 'items', 'biblio' );
+our @tables_allowed_for_select = ( 'biblioitems', 'items', 'biblio', 'biblio_metadata' );
 unless ( grep { /^$table$/ } @tables_allowed_for_select ) {
     die "Cannot specify -t|--table with value '$table'. Only "
       . ( join ', ', @tables_allowed_for_select )
@@ -169,8 +169,6 @@ my $biblioserverdir = C4::Context->zebraconfig('biblioserver')->{directory};
 my $authorityserverdir = C4::Context->zebraconfig('authorityserver')->{directory};
 
 my $kohadir = C4::Context->config('intranetdir');
-my $bib_index_mode  = C4::Context->config('zebra_bib_index_mode')  // 'dom';
-my $auth_index_mode = C4::Context->config('zebra_auth_index_mode') // 'dom';
 
 my ($biblionumbertagfield,$biblionumbertagsubfield) = C4::Biblio::GetMarcFromKohaField("biblio.biblionumber","");
 my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = C4::Biblio::GetMarcFromKohaField("biblioitems.biblioitemnumber","");
@@ -281,8 +279,7 @@ if ($keep_export) {
         print "parameter";
     }
     print "\n";
-    print "if you just want to rebuild zebra after changing the record.abs\n";
-    print "or another zebra config file\n";
+    print "if you just want to rebuild zebra after changing zebra config files\n";
 } else {
     unless ($use_tempdir) {
         # if we're using a temporary directory
@@ -479,7 +476,7 @@ sub select_all_authorities {
 sub select_all_biblios {
     $table = 'biblioitems'
       unless grep { /^$table$/ } @tables_allowed_for_select;
-    my $strsth = qq{ SELECT biblionumber FROM $table };
+    my $strsth = qq{ SELECT DISTINCT(biblionumber) FROM $table };
     $strsth.=qq{ WHERE $where } if ($where);
     $strsth.=qq{ LIMIT $length } if ($length && !$offset);
     $strsth.=qq{ LIMIT $offset,$length } if ($offset);
@@ -656,7 +653,7 @@ sub get_corrected_marc_record {
 
             my @filters;
             push @filters, 'EmbedItemsAvailability';
-            push @filters, 'IncludeSeeFromInSearches'
+            push @filters, 'EmbedSeeFromHeadings'
                 if C4::Context->preference('IncludeSeeFromInSearches');
 
             my $normalizer = Koha::RecordProcessor->new( { filters => \@filters } );
@@ -920,7 +917,7 @@ Parameters:
                             to wait for the lock to free and then continue
                             processing the rebuild request,
 
-    --table                 specify a table (can be items, biblioitems or biblio) to retrieve biblionumber to index.
+    --table                 specify a table (can be items, biblioitems, biblio, biblio_metadata) to retrieve biblionumber to index.
                             biblioitems is the default value.
 
     --help or -h            show this message.