From 384fca1cf4d4f12a46e94ed38f410a08423c8d33 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 14 Mar 2013 13:00:14 -0300 Subject: [PATCH] Bug 7440 - Remove NoZebra vestiges MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed NoZebra vestiges. This comprises several code blocks that depend on the NoZebra syspref and NZ related functions/methods. C4::Biblio-> GetNoZebraIndexes _DelBiblioNoZebra _AddBiblioNoZebra C4::Search-> NZgetRecords NZanalyse NZoperatorAND NZoperatorOR NZoperatorNOT NZorder C4::Installer-> set_indexing_engine Sponsored-by: Universidad Nacional de Córdoba --- C4/Auth.pm | 1 - C4/AuthoritiesMarc.pm | 464 +++++------- C4/Biblio.pm | 379 +--------- C4/Installer.pm | 26 - C4/Items.pm | 28 +- C4/Search.pm | 738 ++------------------ INSTALL.fedora7 | 3 +- about.pl | 2 - catalogue/search.pl | 16 +- installer/data/mysql/kohastructure.sql | 14 - ...m_preferences_full_optimal_for_install_only.sql | 2 - ...stem_preferences_optimal_values_insert_only.sql | 2 - installer/data/mysql/sysprefs.sql | 3 - ...m_preferences_full_optimal_for_install_only.sql | 28 - ...stem_preferences_optimal_values_insert_only.sql | 28 - installer/install.pl | 1 - .../intranet-tmpl/prog/en/includes/admin-menu.inc | 1 - koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 5 +- .../prog/en/modules/admin/admin-home.tt | 2 - .../prog/en/modules/catalogue/results.tt | 40 -- misc/migration_tools/rebuild_nozebra.pl | 343 --------- misc/migration_tools/rebuild_zebra.pl | 4 +- opac/opac-search.pl | 7 +- t/db_dependent/Search.t | 4 +- t/db_dependent/lib/KohaTest.pm | 8 - t/db_dependent/lib/KohaTest/Biblio.pm | 3 - .../lib/KohaTest/Biblio/GetNoZebraIndexes.pm | 72 -- t/db_dependent/lib/KohaTest/Installer.pm | 1 - t/db_dependent/lib/KohaTest/Search.pm | 6 - t/db_dependent/lib/KohaTest/Search/NoZebra.pm | 235 ------- 30 files changed, 290 insertions(+), 2176 deletions(-) delete mode 100755 misc/migration_tools/rebuild_nozebra.pl delete mode 100644 t/db_dependent/lib/KohaTest/Biblio/GetNoZebraIndexes.pm delete mode 100644 t/db_dependent/lib/KohaTest/Search/NoZebra.pm diff --git a/C4/Auth.pm b/C4/Auth.pm index efe1200..b459563 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -362,7 +362,6 @@ sub get_template_and_user { suggestion => C4::Context->preference("suggestion"), virtualshelves => C4::Context->preference("virtualshelves"), StaffSerialIssueDisplayCount => C4::Context->preference("StaffSerialIssueDisplayCount"), - NoZebra => C4::Context->preference('NoZebra'), EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'), LocalCoverImages => C4::Context->preference('LocalCoverImages'), OPACLocalCoverImages => C4::Context->preference('OPACLocalCoverImages'), diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index a2da403..24a9de9 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -109,305 +109,213 @@ sub SearchAuthorities { my ($tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby,$skipmetadata) = @_; # warn Dumper($tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby); my $dbh=C4::Context->dbh; - if (C4::Context->preference('NoZebra')) { - - # - # build the query - # - my $query; + my $query; + my $qpquery = ''; + my $QParser; + $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser')); + my $attr = ''; + # the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on + # the authtypecode. Then, search on $a of this tag_to_report + # also store main entry MARC tag, to extract it at end of search + my $mainentrytag; + ##first set the authtype search and may be multiple authorities + if ($authtypecode) { + my $n=0; + my @authtypecode; my @auths=split / /,$authtypecode ; foreach my $auth (@auths){ - $query .="AND auth_type= $auth "; + $query .=" \@attr 1=authtype \@attr 5=100 ".$auth; ##No truncation on authtype + push @authtypecode ,$auth; + $n++; } - $query =~ s/^AND //; - my $dosearch; - for(my $i = 0 ; $i <= $#{$value} ; $i++) - { - if (@$value[$i]){ - if (@$tags[$i] =~/mainentry|mainmainentry/) { - $query .= qq( AND @$tags[$i] ); - } else { - $query .=" AND "; - } - if (@$operator[$i] eq 'is') { - $query.=(@$tags[$i]?"=":""). '"'.@$value[$i].'"'; - }elsif (@$operator[$i] eq "="){ - $query.=(@$tags[$i]?"=":""). '"'.@$value[$i].'"'; - }elsif (@$operator[$i] eq "start"){ - $query.=(@$tags[$i]?"=":"").'"'.@$value[$i].'%"'; - } else { - $query.=(@$tags[$i]?"=":"").'"'.@$value[$i].'%"'; - } - $dosearch=1; - }#if value + if ($n>1){ + while ($n>1){$query= "\@or ".$query;$n--;} } - # - # do the query (if we had some search term - # - if ($dosearch) { -# warn "QUERY : $query"; - my $result = C4::Search::NZanalyse($query,'authorityserver'); -# warn "result : $result"; - my %result; - foreach (split /;/,$result) { - my ($authid,$title) = split /,/,$_; - # hint : the result is sorted by title.biblionumber because we can have X biblios with the same title - # and we don't want to get only 1 result for each of them !!! - # hint & speed improvement : we can order without reading the record - # so order, and read records only for the requested page ! - $result{$title.$authid}=$authid; + if ($QParser) { + $qpquery .= '(authtype:' . join('|| authtype:', @auths) . ')'; + } + } + + my $dosearch; + my $and=" \@and " ; + my $q2; + my $attr_cnt = 0; + for(my $i = 0 ; $i <= $#{$value} ; $i++) + { + if (@$value[$i]){ + if ( @$tags[$i] eq "mainmainentry" ) { + $attr = " \@attr 1=Heading-Main "; } - # sort the hash and return the same structure as GetRecords (Zebra querying) - my @listresult = (); - my $numbers=0; - if ($sortby eq 'HeadingDsc') { # sort by mainmainentry desc - foreach my $key (sort {$b cmp $a} (keys %result)) { - push @listresult, $result{$key}; -# warn "push..."$#finalresult; - $numbers++; - } - } else { # sort by mainmainentry ASC - foreach my $key (sort (keys %result)) { - push @listresult, $result{$key}; -# warn "push..."$#finalresult; - $numbers++; - } + elsif ( @$tags[$i] eq "mainentry" ) { + $attr = " \@attr 1=Heading "; } - # limit the $results_per_page to result size if it's more - $length = $numbers-$offset if $numbers < ($offset+$length); - # for the requested page, replace authid by the complete record - # speed improvement : avoid reading too much things - my @finalresult; - for (my $counter=$offset;$counter<=$offset+$length-1;$counter++) { -# $finalresult[$counter] = GetAuthority($finalresult[$counter])->as_usmarc; - my $separator=C4::Context->preference('authoritysep'); - my $authrecord =GetAuthority($listresult[$counter]); - my $authid=$listresult[$counter]; - my $summary=BuildSummary($authrecord,$authid,$authtypecode); - my $query_auth_tag = "SELECT auth_tag_to_report FROM auth_types WHERE authtypecode=?"; - my $sth = $dbh->prepare($query_auth_tag); - $sth->execute($authtypecode); - my $auth_tag_to_report = $sth->fetchrow; - my %newline; - $newline{used}=CountUsage($authid); - $newline{summary} = $summary; - $newline{authid} = $authid; - $newline{even} = $counter % 2; - push @finalresult, \%newline; + elsif ( @$tags[$i] eq "match" ) { + $attr = " \@attr 1=Match "; } - return (\@finalresult, $numbers); - } else { - return; - } - } else { - my $query; - my $qpquery = ''; - my $QParser; - $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser')); - my $attr = ''; - # the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on - # the authtypecode. Then, search on $a of this tag_to_report - # also store main entry MARC tag, to extract it at end of search - my $mainentrytag; - ##first set the authtype search and may be multiple authorities - if ($authtypecode) { - my $n=0; - my @authtypecode; - my @auths=split / /,$authtypecode ; - foreach my $auth (@auths){ - $query .=" \@attr 1=authtype \@attr 5=100 ".$auth; ##No truncation on authtype - push @authtypecode ,$auth; - $n++; + elsif ( @$tags[$i] eq "match-heading" ) { + $attr = " \@attr 1=Match-heading "; + } + elsif ( @$tags[$i] eq "see-from" ) { + $attr = " \@attr 1=Match-heading-see-from "; + } + elsif ( @$tags[$i] eq "thesaurus" ) { + $attr = " \@attr 1=Subject-heading-thesaurus "; + } + else { # Assume any if no index was specified + $attr = " \@attr 1=Any "; } - if ($n>1){ - while ($n>1){$query= "\@or ".$query;$n--;} + if ( @$operator[$i] eq 'is' ) { + $attr .= " \@attr 4=1 \@attr 5=100 " + ; ##Phrase, No truncation,all of subfield field must match + } + elsif ( @$operator[$i] eq "=" ) { + $attr .= " \@attr 4=107 "; #Number Exact match + } + elsif ( @$operator[$i] eq "start" ) { + $attr .= " \@attr 3=2 \@attr 4=1 \@attr 5=1 " + ; #Firstinfield Phrase, Right truncated + } + elsif ( @$operator[$i] eq "exact" ) { + $attr .= " \@attr 4=1 \@attr 5=100 \@attr 6=3 " + ; ##Phrase, No truncation,all of subfield field must match + } + else { + $attr .= " \@attr 5=1 \@attr 4=6 " + ; ## Word list, right truncated, anywhere + if ($sortby eq 'Relevance') { + $attr .= "\@attr 2=102 "; + } } + @$value[$i] =~ s/"/\\"/g; # Escape the double-quotes in the search value + $attr =$attr."\"".@$value[$i]."\""; + $q2 .=$attr; + $dosearch=1; + ++$attr_cnt; if ($QParser) { - $qpquery .= '(authtype:' . join('|| authtype:', @auths) . ')'; + $qpquery .= " $tags->[$i]:\"$value->[$i]\""; } - } - - my $dosearch; - my $and=" \@and " ; - my $q2; - my $attr_cnt = 0; - for(my $i = 0 ; $i <= $#{$value} ; $i++) - { - if (@$value[$i]){ - if ( @$tags[$i] eq "mainmainentry" ) { - $attr = " \@attr 1=Heading-Main "; - } - elsif ( @$tags[$i] eq "mainentry" ) { - $attr = " \@attr 1=Heading "; - } - elsif ( @$tags[$i] eq "match" ) { - $attr = " \@attr 1=Match "; - } - elsif ( @$tags[$i] eq "match-heading" ) { - $attr = " \@attr 1=Match-heading "; - } - elsif ( @$tags[$i] eq "see-from" ) { - $attr = " \@attr 1=Match-heading-see-from "; - } - elsif ( @$tags[$i] eq "thesaurus" ) { - $attr = " \@attr 1=Subject-heading-thesaurus "; - } - else { # Assume any if no index was specified - $attr = " \@attr 1=Any "; - } - if ( @$operator[$i] eq 'is' ) { - $attr .= " \@attr 4=1 \@attr 5=100 " - ; ##Phrase, No truncation,all of subfield field must match - } - elsif ( @$operator[$i] eq "=" ) { - $attr .= " \@attr 4=107 "; #Number Exact match - } - elsif ( @$operator[$i] eq "start" ) { - $attr .= " \@attr 3=2 \@attr 4=1 \@attr 5=1 " - ; #Firstinfield Phrase, Right truncated - } - elsif ( @$operator[$i] eq "exact" ) { - $attr .= " \@attr 4=1 \@attr 5=100 \@attr 6=3 " - ; ##Phrase, No truncation,all of subfield field must match - } - else { - $attr .= " \@attr 5=1 \@attr 4=6 " - ; ## Word list, right truncated, anywhere - if ($sortby eq 'Relevance') { - $attr .= "\@attr 2=102 "; - } - } - @$value[$i] =~ s/"/\\"/g; # Escape the double-quotes in the search value - $attr =$attr."\"".@$value[$i]."\""; - $q2 .=$attr; - $dosearch=1; - ++$attr_cnt; - if ($QParser) { - $qpquery .= " $tags->[$i]:\"$value->[$i]\""; - } - }#if value - } - ##Add how many queries generated - if (defined $query && $query=~/\S+/){ - $query= $and x $attr_cnt . $query . (defined $q2 ? $q2 : ''); - } else { - $query= $q2; - } - ## Adding order - #$query=' @or @attr 7=2 @attr 1=Heading 0 @or @attr 7=1 @attr 1=Heading 1'.$query if ($sortby eq "HeadingDsc"); - my $orderstring; - if ($sortby eq 'HeadingAsc') { - $orderstring = '@attr 7=1 @attr 1=Heading 0'; - } elsif ($sortby eq 'HeadingDsc') { - $orderstring = '@attr 7=2 @attr 1=Heading 0'; - } elsif ($sortby eq 'AuthidAsc') { - $orderstring = '@attr 7=1 @attr 4=109 @attr 1=Local-Number 0'; - } elsif ($sortby eq 'AuthidDsc') { - $orderstring = '@attr 7=2 @attr 4=109 @attr 1=Local-Number 0'; - } - if ($QParser) { - $qpquery .= ' all:all' unless $value->[0]; + }#if value + } + ##Add how many queries generated + if (defined $query && $query=~/\S+/){ + $query= $and x $attr_cnt . $query . (defined $q2 ? $q2 : ''); + } else { + $query= $q2; + } + ## Adding order + #$query=' @or @attr 7=2 @attr 1=Heading 0 @or @attr 7=1 @attr 1=Heading 1'.$query if ($sortby eq "HeadingDsc"); + my $orderstring; + if ($sortby eq 'HeadingAsc') { + $orderstring = '@attr 7=1 @attr 1=Heading 0'; + } elsif ($sortby eq 'HeadingDsc') { + $orderstring = '@attr 7=2 @attr 1=Heading 0'; + } elsif ($sortby eq 'AuthidAsc') { + $orderstring = '@attr 7=1 @attr 4=109 @attr 1=Local-Number 0'; + } elsif ($sortby eq 'AuthidDsc') { + $orderstring = '@attr 7=2 @attr 4=109 @attr 1=Local-Number 0'; + } + if ($QParser) { + $qpquery .= ' all:all' unless $value->[0]; - if ( $value->[0] =~ m/^qp=(.*)$/ ) { - $qpquery = $1; - } + if ( $value->[0] =~ m/^qp=(.*)$/ ) { + $qpquery = $1; + } - $qpquery .= " #$sortby"; + $qpquery .= " #$sortby"; - $QParser->parse( $qpquery ); - $query = $QParser->target_syntax('authorityserver'); - } else { - $query=($query?$query:"\@attr 1=_ALLRECORDS \@attr 2=103 ''"); - $query="\@or $orderstring $query" if $orderstring; - } + $QParser->parse( $qpquery ); + $query = $QParser->target_syntax('authorityserver'); + } else { + $query=($query?$query:"\@attr 1=_ALLRECORDS \@attr 2=103 ''"); + $query="\@or $orderstring $query" if $orderstring; + } - $offset=0 unless $offset; - my $counter = $offset; - $length=10 unless $length; - my @oAuth; - my $i; - $oAuth[0]=C4::Context->Zconn("authorityserver" , 1); - my $Anewq= new ZOOM::Query::PQF($query,$oAuth[0]); - my $oAResult; - $oAResult= $oAuth[0]->search($Anewq) ; - while (($i = ZOOM::event(\@oAuth)) != 0) { - my $ev = $oAuth[$i-1]->last_event(); - last if $ev == ZOOM::Event::ZEND; - } - my($error, $errmsg, $addinfo, $diagset) = $oAuth[0]->error_x(); - if ($error) { - warn "oAuth error: $errmsg ($error) $addinfo $diagset\n"; - goto NOLUCK; - } - - my $nbresults; - $nbresults=$oAResult->size(); - my $nremains=$nbresults; - my @result = (); - my @finalresult = (); - - if ($nbresults>0){ + $offset=0 unless $offset; + my $counter = $offset; + $length=10 unless $length; + my @oAuth; + my $i; + $oAuth[0]=C4::Context->Zconn("authorityserver" , 1); + my $Anewq= new ZOOM::Query::PQF($query,$oAuth[0]); + my $oAResult; + $oAResult= $oAuth[0]->search($Anewq) ; + while (($i = ZOOM::event(\@oAuth)) != 0) { + my $ev = $oAuth[$i-1]->last_event(); + last if $ev == ZOOM::Event::ZEND; + } + my($error, $errmsg, $addinfo, $diagset) = $oAuth[0]->error_x(); + if ($error) { + warn "oAuth error: $errmsg ($error) $addinfo $diagset\n"; + goto NOLUCK; + } + + my $nbresults; + $nbresults=$oAResult->size(); + my $nremains=$nbresults; + my @result = (); + my @finalresult = (); + + if ($nbresults>0){ + + ##Find authid and linkid fields + ##we may be searching multiple authoritytypes. + ## FIXME this assumes that all authid and linkid fields are the same for all authority types + # my ($authidfield,$authidsubfield)=GetAuthMARCFromKohaField($dbh,"auth_header.authid",$authtypecode[0]); + # my ($linkidfield,$linkidsubfield)=GetAuthMARCFromKohaField($dbh,"auth_header.linkid",$authtypecode[0]); + while (($counter < $nbresults) && ($counter < ($offset + $length))) { - ##Find authid and linkid fields - ##we may be searching multiple authoritytypes. - ## FIXME this assumes that all authid and linkid fields are the same for all authority types - # my ($authidfield,$authidsubfield)=GetAuthMARCFromKohaField($dbh,"auth_header.authid",$authtypecode[0]); - # my ($linkidfield,$linkidsubfield)=GetAuthMARCFromKohaField($dbh,"auth_header.linkid",$authtypecode[0]); - while (($counter < $nbresults) && ($counter < ($offset + $length))) { - - ##Here we have to extract MARC record and $authid from ZEBRA AUTHORITIES - my $rec=$oAResult->record($counter); - my $marcdata=$rec->raw(); - my $authrecord; - my $separator=C4::Context->preference('authoritysep'); - $authrecord = MARC::File::USMARC::decode($marcdata); - my $authid=$authrecord->field('001')->data(); - my %newline; - $newline{authid} = $authid; - if ( !$skipmetadata ) { - my $summary = - BuildSummary( $authrecord, $authid, $authtypecode ); - my $query_auth_tag = + ##Here we have to extract MARC record and $authid from ZEBRA AUTHORITIES + my $rec=$oAResult->record($counter); + my $marcdata=$rec->raw(); + my $authrecord; + my $separator=C4::Context->preference('authoritysep'); + $authrecord = MARC::File::USMARC::decode($marcdata); + my $authid=$authrecord->field('001')->data(); + my %newline; + $newline{authid} = $authid; + if ( !$skipmetadata ) { + my $summary = + BuildSummary( $authrecord, $authid, $authtypecode ); + my $query_auth_tag = "SELECT auth_tag_to_report FROM auth_types WHERE authtypecode=?"; - my $sth = $dbh->prepare($query_auth_tag); - $sth->execute($authtypecode); - my $auth_tag_to_report = $sth->fetchrow; - my $reported_tag; - my $mainentry = $authrecord->field($auth_tag_to_report); - if ($mainentry) { - - foreach ( $mainentry->subfields() ) { - $reported_tag .= '$' . $_->[0] . $_->[1]; - } + my $sth = $dbh->prepare($query_auth_tag); + $sth->execute($authtypecode); + my $auth_tag_to_report = $sth->fetchrow; + my $reported_tag; + my $mainentry = $authrecord->field($auth_tag_to_report); + if ($mainentry) { + + foreach ( $mainentry->subfields() ) { + $reported_tag .= '$' . $_->[0] . $_->[1]; } - my $thisauthtype = GetAuthType(GetAuthTypeCode($authid)); - unless (defined $thisauthtype) { - $thisauthtype = GetAuthType($authtypecode) if $authtypecode; - } - $newline{authtype} = defined($thisauthtype) ? - $thisauthtype->{'authtypetext'} : ''; - $newline{summary} = $summary; - $newline{even} = $counter % 2; - $newline{reported_tag} = $reported_tag; } - $counter++; - push @finalresult, \%newline; - }## while counter - ### - if (! $skipmetadata) { - for (my $z=0; $z<@finalresult; $z++){ - my $count=CountUsage($finalresult[$z]{authid}); - $finalresult[$z]{used}=$count; - }# all $z's + my $thisauthtype = GetAuthType(GetAuthTypeCode($authid)); + unless (defined $thisauthtype) { + $thisauthtype = GetAuthType($authtypecode) if $authtypecode; } + $newline{authtype} = defined($thisauthtype) ? + $thisauthtype->{'authtypetext'} : ''; + $newline{summary} = $summary; + $newline{even} = $counter % 2; + $newline{reported_tag} = $reported_tag; + } + $counter++; + push @finalresult, \%newline; + }## while counter + ### + if (! $skipmetadata) { + for (my $z=0; $z<@finalresult; $z++){ + my $count=CountUsage($finalresult[$z]{authid}); + $finalresult[$z]{used}=$count; + }# all $z's + } - }## if nbresult - NOLUCK: - $oAResult->destroy(); - # $oAuth[0]->destroy(); - - return (\@finalresult, $nbresults); - } + }## if nbresult + NOLUCK: + $oAResult->destroy(); + # $oAuth[0]->destroy(); + + return (\@finalresult, $nbresults); } =head2 CountUsage diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 16134d4..7af8619 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -136,7 +136,6 @@ BEGIN { &TransformHtmlToMarc2 &TransformHtmlToMarc &TransformHtmlToXml - &GetNoZebraIndexes prepare_host_field ); } @@ -444,17 +443,9 @@ sub DelBiblio { # Delete in Zebra. Be careful NOT to move this line after _koha_delete_biblio # for at least 2 reasons : - # - we need to read the biblio if NoZebra is set (to remove it from the indexes # - if something goes wrong, the biblio may be deleted from Koha but not from zebra # and we would have no way to remove it (except manually in zebra, but I bet it would be very hard to handle the problem) - my $oldRecord; - if ( C4::Context->preference("NoZebra") ) { - - # only NoZebra indexing needs to have - # the previous version of the record - $oldRecord = GetMarcBiblio($biblionumber); - } - ModZebra( $biblionumber, "recordDelete", "biblioserver", $oldRecord, undef ); + ModZebra( $biblionumber, "recordDelete", "biblioserver" ); # delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems $sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); @@ -2760,7 +2751,7 @@ sub TransformMarcToKohaOneField { =head2 ModZebra - ModZebra( $biblionumber, $op, $server, $oldRecord, $newRecord ); + ModZebra( $biblionumber, $op, $server ); $biblionumber is the biblionumber we want to index @@ -2768,99 +2759,34 @@ $op is specialUpdate or delete, and is used to know what we want to do $server is the server that we want to update -$oldRecord is the MARC::Record containing the previous version of the record. This is used only when -NoZebra=1, as NoZebra indexing needs to know the previous version of a record in order to -do an update. - -$newRecord is the MARC::Record containing the new record. It is usefull only when NoZebra=1, and is used to know what to add to the nozebra database. (the record in mySQL being, if it exist, the previous record, the one just before the modif. We need both : the previous and the new one. - =cut sub ModZebra { ###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs - my ( $biblionumber, $op, $server, $oldRecord, $newRecord ) = @_; + my ( $biblionumber, $op, $server ) = @_; my $dbh = C4::Context->dbh; # true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates # at the same time # replaced by a zebraqueue table, that is filled with ModZebra to run. - # the table is emptied by misc/cronjobs/zebraqueue_start.pl script + # the table is emptied by rebuild_zebra.pl script (using the -z switch) - if ( C4::Context->preference("NoZebra") ) { - - # lock the nozebra table : we will read index lines, update them in Perl process - # and write everything in 1 transaction. - # lock the table to avoid someone else overwriting what we are doing - $dbh->do('LOCK TABLES nozebra WRITE,biblio WRITE,biblioitems WRITE, systempreferences WRITE, auth_types WRITE, auth_header WRITE, auth_subfield_structure READ'); - my %result; # the result hash that will be built by deletion / add, and written on mySQL at the end, to improve speed - if ( $op eq 'specialUpdate' ) { - - # OK, we have to add or update the record - # 1st delete (virtually, in indexes), if record actually exists - if ($oldRecord) { - %result = _DelBiblioNoZebra( $biblionumber, $oldRecord, $server ); - } - - # ... add the record - %result = _AddBiblioNoZebra( $biblionumber, $newRecord, $server, %result ); - } else { - - # it's a deletion, delete the record... - # warn "DELETE the record $biblionumber on $server".$record->as_formatted; - %result = _DelBiblioNoZebra( $biblionumber, $oldRecord, $server ); - } - - # ok, now update the database... - my $sth = $dbh->prepare("UPDATE nozebra SET biblionumbers=? WHERE server=? AND indexname=? AND value=?"); - foreach my $key ( keys %result ) { - foreach my $index ( keys %{ $result{$key} } ) { - $sth->execute( $result{$key}->{$index}, $server, $key, $index ); - } - } - $dbh->do('UNLOCK TABLES'); - } else { - - # - # we use zebra, just fill zebraqueue table - # - my $check_sql = "SELECT COUNT(*) FROM zebraqueue - WHERE server = ? - AND biblio_auth_number = ? - AND operation = ? - AND done = 0"; - my $check_sth = $dbh->prepare_cached($check_sql); - $check_sth->execute( $server, $biblionumber, $op ); - my ($count) = $check_sth->fetchrow_array; - $check_sth->finish(); - if ( $count == 0 ) { - my $sth = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); - $sth->execute( $biblionumber, $server, $op ); - $sth->finish; - } + my $check_sql = "SELECT COUNT(*) FROM zebraqueue + WHERE server = ? + AND biblio_auth_number = ? + AND operation = ? + AND done = 0"; + my $check_sth = $dbh->prepare_cached($check_sql); + $check_sth->execute( $server, $biblionumber, $op ); + my ($count) = $check_sth->fetchrow_array; + $check_sth->finish(); + if ( $count == 0 ) { + my $sth = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); + $sth->execute( $biblionumber, $server, $op ); + $sth->finish; } } -=head2 GetNoZebraIndexes - - %indexes = GetNoZebraIndexes; - -return the data from NoZebraIndexes syspref. - -=cut - -sub GetNoZebraIndexes { - my $no_zebra_indexes = C4::Context->preference('NoZebraIndexes'); - my %indexes; - INDEX: foreach my $line ( split /['"],[\n\r]*/, $no_zebra_indexes ) { - $line =~ /(.*)=>(.*)/; - my $index = $1; # initial ' or " is removed afterwards - my $fields = $2; - $index =~ s/'|"|\s//g; - $fields =~ s/'|"|\s//g; - $indexes{$index} = $fields; - } - return %indexes; -} =head2 EmbedItemsInMarcBiblio @@ -2899,268 +2825,6 @@ sub EmbedItemsInMarcBiblio { =head1 INTERNAL FUNCTIONS -=head2 _DelBiblioNoZebra($biblionumber,$record,$server); - -function to delete a biblio in NoZebra indexes -This function does NOT delete anything in database : it reads all the indexes entries -that have to be deleted & delete them in the hash - -The SQL part is done either : - - after the Add if we are modifying a biblio (delete + add again) - - immediatly after this sub if we are doing a true deletion. - -$server can be 'biblioserver' or 'authorityserver' : it indexes biblios or authorities (in the same table, $server being part of the table itself - -=cut - -sub _DelBiblioNoZebra { - my ( $biblionumber, $record, $server ) = @_; - - # Get the indexes - my $dbh = C4::Context->dbh; - - # Get the indexes - my %index; - my $title; - if ( $server eq 'biblioserver' ) { - %index = GetNoZebraIndexes; - - # get title of the record (to store the 10 first letters with the index) - my ( $titletag, $titlesubfield ) = GetMarcFromKohaField( 'biblio.title', '' ); # FIXME: should be GetFrameworkCode($biblionumber) ?? - $title = lc( $record->subfield( $titletag, $titlesubfield ) ); - } else { - - # for authorities, the "title" is the $a mainentry - my ( $auth_type_tag, $auth_type_sf ) = C4::AuthoritiesMarc::get_auth_type_location(); - my $authref = C4::AuthoritiesMarc::GetAuthType( $record->subfield( $auth_type_tag, $auth_type_sf ) ); - warn "ERROR : authtype undefined for " . $record->as_formatted unless $authref; - $title = $record->subfield( $authref->{auth_tag_to_report}, 'a' ); - $index{'mainmainentry'} = $authref->{'auth_tag_to_report'} . 'a'; - $index{'mainentry'} = $authref->{'auth_tag_to_report'} . '*'; - $index{'auth_type'} = "${auth_type_tag}${auth_type_sf}"; - } - - my %result; - - # remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values - $title =~ s/ |,|;|\[|\]|\(|\)|\*|-|'|=//g; - - # limit to 10 char, should be enough, and limit the DB size - $title = substr( $title, 0, 10 ); - - #parse each field - my $sth2 = $dbh->prepare('SELECT biblionumbers FROM nozebra WHERE server=? AND indexname=? AND value=?'); - foreach my $field ( $record->fields() ) { - - #parse each subfield - next if $field->tag < 10; - foreach my $subfield ( $field->subfields() ) { - my $tag = $field->tag(); - my $subfieldcode = $subfield->[0]; - my $indexed = 0; - - # check each index to see if the subfield is stored somewhere - # otherwise, store it in __RAW__ index - foreach my $key ( keys %index ) { - - # warn "examining $key index : ".$index{$key}." for $tag $subfieldcode"; - if ( $index{$key} =~ /$tag\*/ or $index{$key} =~ /$tag$subfieldcode/ ) { - $indexed = 1; - my $line = lc $subfield->[1]; - - # remove meaningless value in the field... - $line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:/ /g; - - # ... and split in words - foreach ( split / /, $line ) { - next unless $_; # skip empty values (multiple spaces) - # if the entry is already here, do nothing, the biblionumber has already be removed - unless ( defined( $result{$key}->{$_} ) && ( $result{$key}->{$_} =~ /$biblionumber,$title\-(\d);/ ) ) { - - # get the index value if it exist in the nozebra table and remove the entry, otherwise, do nothing - $sth2->execute( $server, $key, $_ ); - my $existing_biblionumbers = $sth2->fetchrow; - - # it exists - if ($existing_biblionumbers) { - - # warn " existing for $key $_: $existing_biblionumbers"; - $result{$key}->{$_} = $existing_biblionumbers; - $result{$key}->{$_} =~ s/$biblionumber,$title\-(\d);//; - } - } - } - } - } - - # the subfield is not indexed, store it in __RAW__ index anyway - unless ($indexed) { - my $line = lc $subfield->[1]; - $line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:/ /g; - - # ... and split in words - foreach ( split / /, $line ) { - next unless $_; # skip empty values (multiple spaces) - # if the entry is already here, do nothing, the biblionumber has already be removed - unless ( $result{'__RAW__'}->{$_} =~ /$biblionumber,$title\-(\d);/ ) { - - # get the index value if it exist in the nozebra table and remove the entry, otherwise, do nothing - $sth2->execute( $server, '__RAW__', $_ ); - my $existing_biblionumbers = $sth2->fetchrow; - - # it exists - if ($existing_biblionumbers) { - $result{'__RAW__'}->{$_} = $existing_biblionumbers; - $result{'__RAW__'}->{$_} =~ s/$biblionumber,$title\-(\d);//; - } - } - } - } - } - } - return %result; -} - -=head2 _AddBiblioNoZebra - - _AddBiblioNoZebra($biblionumber, $record, $server, %result); - -function to add a biblio in NoZebra indexes - -=cut - -sub _AddBiblioNoZebra { - my ( $biblionumber, $record, $server, %result ) = @_; - my $dbh = C4::Context->dbh; - - # Get the indexes - my %index; - my $title; - if ( $server eq 'biblioserver' ) { - %index = GetNoZebraIndexes; - - # get title of the record (to store the 10 first letters with the index) - my ( $titletag, $titlesubfield ) = GetMarcFromKohaField( 'biblio.title', '' ); # FIXME: should be GetFrameworkCode($biblionumber) ?? - $title = lc( $record->subfield( $titletag, $titlesubfield ) ); - } else { - - # warn "server : $server"; - # for authorities, the "title" is the $a mainentry - my ( $auth_type_tag, $auth_type_sf ) = C4::AuthoritiesMarc::get_auth_type_location(); - my $authref = C4::AuthoritiesMarc::GetAuthType( $record->subfield( $auth_type_tag, $auth_type_sf ) ); - warn "ERROR : authtype undefined for " . $record->as_formatted unless $authref; - $title = $record->subfield( $authref->{auth_tag_to_report}, 'a' ); - $index{'mainmainentry'} = $authref->{auth_tag_to_report} . 'a'; - $index{'mainentry'} = $authref->{auth_tag_to_report} . '*'; - $index{'auth_type'} = "${auth_type_tag}${auth_type_sf}"; - } - - # remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values - $title =~ s/ |\.|,|;|\[|\]|\(|\)|\*|-|'|:|=|\r|\n//g; - - # limit to 10 char, should be enough, and limit the DB size - $title = substr( $title, 0, 10 ); - - #parse each field - my $sth2 = $dbh->prepare('SELECT biblionumbers FROM nozebra WHERE server=? AND indexname=? AND value=?'); - foreach my $field ( $record->fields() ) { - - #parse each subfield - ###FIXME: impossible to index a 001-009 value with NoZebra - next if $field->tag < 10; - foreach my $subfield ( $field->subfields() ) { - my $tag = $field->tag(); - my $subfieldcode = $subfield->[0]; - my $indexed = 0; - - # warn "INDEXING :".$subfield->[1]; - # check each index to see if the subfield is stored somewhere - # otherwise, store it in __RAW__ index - foreach my $key ( keys %index ) { - - # warn "examining $key index : ".$index{$key}." for $tag $subfieldcode"; - if ( $index{$key} =~ /$tag\*/ or $index{$key} =~ /$tag$subfieldcode/ ) { - $indexed = 1; - my $line = lc $subfield->[1]; - - # remove meaningless value in the field... - $line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:|\r|\n/ /g; - - # ... and split in words - foreach ( split / /, $line ) { - next unless $_; # skip empty values (multiple spaces) - # if the entry is already here, improve weight - - # warn "managing $_"; - if ( exists $result{$key}->{$_} && $result{$key}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d+);/ ) { - my $weight = $1 + 1; - $result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g; - $result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; - } else { - - # get the value if it exist in the nozebra table, otherwise, create it - $sth2->execute( $server, $key, $_ ); - my $existing_biblionumbers = $sth2->fetchrow; - - # it exists - if ($existing_biblionumbers) { - $result{$key}->{"$_"} = $existing_biblionumbers; - my $weight = defined $1 ? $1 + 1 : 1; - $result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g; - $result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; - - # create a new ligne for this entry - } else { - - # warn "INSERT : $server / $key / $_"; - $dbh->do( 'INSERT INTO nozebra SET server=' . $dbh->quote($server) . ', indexname=' . $dbh->quote($key) . ',value=' . $dbh->quote($_) ); - $result{$key}->{"$_"} .= "$biblionumber,$title-1;"; - } - } - } - } - } - - # the subfield is not indexed, store it in __RAW__ index anyway - unless ($indexed) { - my $line = lc $subfield->[1]; - $line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:|\r|\n/ /g; - - # ... and split in words - foreach ( split / /, $line ) { - next unless $_; # skip empty values (multiple spaces) - # if the entry is already here, improve weight - my $tmpstr = $result{'__RAW__'}->{"$_"} || ""; - if ( $tmpstr =~ /$biblionumber,\Q$title\E\-(\d+);/ ) { - my $weight = $1 + 1; - $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//; - $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; - } else { - - # get the value if it exist in the nozebra table, otherwise, create it - $sth2->execute( $server, '__RAW__', $_ ); - my $existing_biblionumbers = $sth2->fetchrow; - - # it exists - if ($existing_biblionumbers) { - $result{'__RAW__'}->{"$_"} = $existing_biblionumbers; - my $weight = ( $1 ? $1 : 0 ) + 1; - $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//; - $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; - - # create a new ligne for this entry - } else { - $dbh->do( 'INSERT INTO nozebra SET server=' . $dbh->quote($server) . ', indexname="__RAW__",value=' . $dbh->quote($_) ); - $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-1;"; - } - } - } - } - } - } - return %result; -} - =head2 _koha_marc_update_bib_ids @@ -3641,17 +3305,10 @@ sub ModBiblioMarc { $f005->update(sprintf("%4d%02d%02d%02d%02d%04.1f",@a)) if $f005; } - my $oldRecord; - if ( C4::Context->preference("NoZebra") ) { - - # only NoZebra indexing needs to have - # the previous version of the record - $oldRecord = GetMarcBiblio($biblionumber); - } $sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE biblionumber=?"); $sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding), $biblionumber ); $sth->finish; - ModZebra( $biblionumber, "specialUpdate", "biblioserver", $oldRecord, $record ); + ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); return $biblionumber; } diff --git a/C4/Installer.pm b/C4/Installer.pm index 304698e..9c173dc 100644 --- a/C4/Installer.pm +++ b/C4/Installer.pm @@ -38,7 +38,6 @@ C4::Installer my ($fwk_language, $error_list) = $installer->load_sql_in_order($all_languages, @$list); $installer->set_version_syspref(); $installer->set_marcflavour_syspref('MARC21'); - $installer->set_indexing_engine(0); =head1 DESCRIPTION @@ -430,31 +429,6 @@ sub set_marcflavour_syspref { $request->execute; } -=head2 set_indexing_engine - - $installer->set_indexing_engine($nozebra); - -Sets system preferences related to the indexing -engine. The C<$nozebra> argument is a boolean; -if true, turn on NoZebra mode and turn off QueryFuzzy, -QueryWeightFields, and QueryStemming. If false, turn -off NoZebra mode (i.e., use the Zebra search engine). - -=cut - -sub set_indexing_engine { - my $self = shift; - my $nozebra = shift; - - if ($nozebra) { - $self->{'dbh'}->do("UPDATE systempreferences SET value=1 WHERE variable='NoZebra'"); - $self->{'dbh'}->do("UPDATE systempreferences SET value=0 WHERE variable in ('QueryFuzzy','QueryWeightFields','QueryStemming')"); - } else { - $self->{'dbh'}->do("UPDATE systempreferences SET value=0 WHERE variable='NoZebra'"); - } - -} - =head2 set_version_syspref $installer->set_version_syspref(); diff --git a/C4/Items.pm b/C4/Items.pm index dbd06b6..6533a68 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -295,7 +295,7 @@ sub AddItem { my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} ); $item->{'itemnumber'} = $itemnumber; - ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver", undef, undef ); + ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" ); logaction("CATALOGUING", "ADD", $itemnumber, "item") if C4::Context->preference("CataloguingLog"); @@ -549,7 +549,7 @@ sub ModItem { # request that bib be reindexed so that searching on current # item status is possible - ModZebra( $biblionumber, "specialUpdate", "biblioserver", undef, undef ); + ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); logaction("CATALOGUING", "MODIFY", $itemnumber, Dumper($item)) if C4::Context->preference("CataloguingLog"); } @@ -615,7 +615,7 @@ sub DelItem { # get the MARC record my $record = GetMarcBiblio($biblionumber); - ModZebra( $biblionumber, "specialUpdate", "biblioserver", undef, undef ); + ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); # backup the record my $copy2deleted = $dbh->prepare("UPDATE deleteditems SET marc=? WHERE itemnumber=?"); @@ -2173,8 +2173,8 @@ sub MoveItemFromBiblio { $sth = $dbh->prepare("UPDATE items SET biblioitemnumber = ?, biblionumber = ? WHERE itemnumber = ? AND biblionumber = ?"); my $return = $sth->execute($tobiblioitem, $tobiblio, $itemnumber, $frombiblio); if ($return == 1) { - ModZebra( $tobiblio, "specialUpdate", "biblioserver", undef, undef ); - ModZebra( $frombiblio, "specialUpdate", "biblioserver", undef, undef ); + ModZebra( $tobiblio, "specialUpdate", "biblioserver" ); + ModZebra( $frombiblio, "specialUpdate", "biblioserver" ); # Checking if the item we want to move is in an order require C4::Acquisition; my $order = C4::Acquisition::GetOrderFromItemnumber($itemnumber); @@ -2460,18 +2460,12 @@ counts Usage of itemnumber in Analytical bibliorecords. sub GetAnalyticsCount { my ($itemnumber) = @_; require C4::Search; - if (C4::Context->preference('NoZebra')) { - # Read the index Koha-Auth-Number for this authid and count the lines - my $result = C4::Search::NZanalyse("hi=$itemnumber"); - my @tab = split /;/,$result; - return scalar @tab; - } else { - ### ZOOM search here - my $query; - $query= "hi=".$itemnumber; - my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10); - return ($result); - } + + ### ZOOM search here + my $query; + $query= "hi=".$itemnumber; + my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10); + return ($result); } =head2 GetItemHolds diff --git a/C4/Search.pm b/C4/Search.pm index 65ad919..e2df744 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -68,7 +68,6 @@ This module provides searching functions for Koha's bibliographic databases &searchResults &getRecords &buildQuery - &NZgetRecords &AddSearchHistory &GetDistinctValues &enabled_staff_search_views @@ -223,91 +222,82 @@ $template->param(result=>\@results); sub SimpleSearch { my ( $query, $offset, $max_results, $servers ) = @_; - if ( C4::Context->preference('NoZebra') ) { - my $result = NZorder( NZanalyse($query) )->{'biblioserver'}; - my $search_result = - ( $result->{hits} - && $result->{hits} > 0 ? $result->{'RECORDS'} : [] ); - return ( undef, $search_result, scalar($result->{hits}) ); - } - else { - return ( 'No query entered', undef, undef ) unless $query; - # FIXME hardcoded value. See catalog/search.pl & opac-search.pl too. - my @servers = defined ( $servers ) ? @$servers : ( 'biblioserver' ); - my @zoom_queries; - my @tmpresults; - my @zconns; - my $results = []; - my $total_hits = 0; + return ( 'No query entered', undef, undef ) unless $query; + # FIXME hardcoded value. See catalog/search.pl & opac-search.pl too. + my @servers = defined ( $servers ) ? @$servers : ( 'biblioserver' ); + my @zoom_queries; + my @tmpresults; + my @zconns; + my $results = []; + my $total_hits = 0; - my $QParser; - $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser') && ! ($query =~ m/\w,\w|\w=\w/)); + my $QParser; + $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser') && ! ($query =~ m/\w,\w|\w=\w/)); - # Initialize & Search Zebra - for ( my $i = 0 ; $i < @servers ; $i++ ) { - eval { - $zconns[$i] = C4::Context->Zconn( $servers[$i], 1 ); - if ($QParser) { - $query =~ s/=/:/g; - $QParser->parse( $query ); - $query = $QParser->target_syntax($servers[$i]); - $zoom_queries[$i] = new ZOOM::Query::PQF( $query, $zconns[$i]); - } else { - $query =~ s/:/=/g; - $zoom_queries[$i] = new ZOOM::Query::CCL2RPN( $query, $zconns[$i]); - } - $tmpresults[$i] = $zconns[$i]->search( $zoom_queries[$i] ); - - # error handling - my $error = - $zconns[$i]->errmsg() . " (" - . $zconns[$i]->errcode() . ") " - . $zconns[$i]->addinfo() . " " - . $zconns[$i]->diagset(); - - return ( $error, undef, undef ) if $zconns[$i]->errcode(); - }; - if ($@) { - - # caught a ZOOM::Exception - my $error = - $@->message() . " (" - . $@->code() . ") " - . $@->addinfo() . " " - . $@->diagset(); - warn $error." for query: $query"; - return ( $error, undef, undef ); + # Initialize & Search Zebra + for ( my $i = 0 ; $i < @servers ; $i++ ) { + eval { + $zconns[$i] = C4::Context->Zconn( $servers[$i], 1 ); + if ($QParser) { + $query =~ s/=/:/g; + $QParser->parse( $query ); + $query = $QParser->target_syntax($servers[$i]); + $zoom_queries[$i] = new ZOOM::Query::PQF( $query, $zconns[$i]); + } else { + $query =~ s/:/=/g; + $zoom_queries[$i] = new ZOOM::Query::CCL2RPN( $query, $zconns[$i]); } - } + $tmpresults[$i] = $zconns[$i]->search( $zoom_queries[$i] ); - _ZOOM_event_loop( - \@zconns, - \@tmpresults, - sub { - my ($i, $size) = @_; - my $first_record = defined($offset) ? $offset + 1 : 1; - my $hits = $tmpresults[ $i - 1 ]->size(); - $total_hits += $hits; - my $last_record = $hits; - if ( defined $max_results && $offset + $max_results < $hits ) { - $last_record = $offset + $max_results; - } + # error handling + my $error = + $zconns[$i]->errmsg() . " (" + . $zconns[$i]->errcode() . ") " + . $zconns[$i]->addinfo() . " " + . $zconns[$i]->diagset(); - for my $j ( $first_record .. $last_record ) { - my $record = - $tmpresults[ $i - 1 ]->record( $j - 1 )->raw() - ; # 0 indexed - push @{$results}, $record; - } + return ( $error, undef, undef ) if $zconns[$i]->errcode(); + }; + if ($@) { + + # caught a ZOOM::Exception + my $error = + $@->message() . " (" + . $@->code() . ") " + . $@->addinfo() . " " + . $@->diagset(); + warn $error." for query: $query"; + return ( $error, undef, undef ); + } + } + + _ZOOM_event_loop( + \@zconns, + \@tmpresults, + sub { + my ($i, $size) = @_; + my $first_record = defined($offset) ? $offset + 1 : 1; + my $hits = $tmpresults[ $i - 1 ]->size(); + $total_hits += $hits; + my $last_record = $hits; + if ( defined $max_results && $offset + $max_results < $hits ) { + $last_record = $offset + $max_results; } - ); - foreach my $zoom_query (@zoom_queries) { - $zoom_query->destroy(); + for my $j ( $first_record .. $last_record ) { + my $record = + $tmpresults[ $i - 1 ]->record( $j - 1 )->raw() + ; # 0 indexed + push @{$results}, $record; + } } + ); - return ( undef, $results, $total_hits ); + foreach my $zoom_query (@zoom_queries) { + $zoom_query->destroy(); } + + return ( undef, $results, $total_hits ); } =head2 getRecords @@ -2171,602 +2161,6 @@ sub SearchAcquisitions{ $qdataacquisitions->finish; return \@loopacquisitions; } -#---------------------------------------------------------------------- -# -# Non-Zebra GetRecords# -#---------------------------------------------------------------------- - -=head2 NZgetRecords - - NZgetRecords has the same API as zera getRecords, even if some parameters are not managed - -=cut - -sub NZgetRecords { - my ( - $query, $simple_query, $sort_by_ref, $servers_ref, - $results_per_page, $offset, $expanded_facet, $branches, - $query_type, $scan - ) = @_; - warn "query =$query" if $DEBUG; - my $result = NZanalyse($query); - warn "results =$result" if $DEBUG; - return ( undef, - NZorder( $result, @$sort_by_ref[0], $results_per_page, $offset ), - undef ); -} - -=head2 NZanalyse - - NZanalyse : get a CQL string as parameter, and returns a list of biblionumber;title,biblionumber;title,... - the list is built from an inverted index in the nozebra SQL table - note that title is here only for convenience : the sorting will be very fast when requested on title - if the sorting is requested on something else, we will have to reread all results, and that may be longer. - -=cut - -sub NZanalyse { - my ( $string, $server ) = @_; -# warn "---------" if $DEBUG; - warn " NZanalyse" if $DEBUG; -# warn "---------" if $DEBUG; - - # $server contains biblioserver or authorities, depending on what we search on. - #warn "querying : $string on $server"; - $server = 'biblioserver' unless $server; - -# if we have a ", replace the content to discard temporarily any and/or/not inside - my $commacontent; - if ( $string =~ /"/ ) { - $string =~ s/"(.*?)"/__X__/; - $commacontent = $1; - warn "commacontent : $commacontent" if $DEBUG; - } - -# split the query string in 3 parts : X AND Y means : $left="X", $operand="AND" and $right="Y" -# then, call again NZanalyse with $left and $right -# (recursive until we find a leaf (=> something without and/or/not) -# delete repeated operator... Would then go in infinite loop - while ( $string =~ s/( and| or| not| AND| OR| NOT)\1/$1/g ) { - } - - #process parenthesis before. - if ( $string =~ /^\s*\((.*)\)(( and | or | not | AND | OR | NOT )(.*))?/ ) { - my $left = $1; - my $right = $4; - my $operator = lc($3); # FIXME: and/or/not are operators, not operands - warn -"dealing w/parenthesis before recursive sub call. left :$left operator:$operator right:$right" - if $DEBUG; - my $leftresult = NZanalyse( $left, $server ); - if ($operator) { - my $rightresult = NZanalyse( $right, $server ); - - # OK, we have the results for right and left part of the query - # depending of operand, intersect, union or exclude both lists - # to get a result list - if ( $operator eq ' and ' ) { - return NZoperatorAND($leftresult,$rightresult); - } - elsif ( $operator eq ' or ' ) { - - # just merge the 2 strings - return $leftresult . $rightresult; - } - elsif ( $operator eq ' not ' ) { - return NZoperatorNOT($leftresult,$rightresult); - } - } - else { -# this error is impossible, because of the regexp that isolate the operand, but just in case... - return $leftresult; - } - } - warn "string :" . $string if $DEBUG; - my $left = ""; - my $right = ""; - my $operator = ""; - if ($string =~ /(.*?)( and | or | not | AND | OR | NOT )(.*)/) { - $left = $1; - $right = $3; - $operator = lc($2); # FIXME: and/or/not are operators, not operands - } - warn "no parenthesis. left : $left operator: $operator right: $right" - if $DEBUG; - - # it's not a leaf, we have a and/or/not - if ($operator) { - - # reintroduce comma content if needed - $right =~ s/__X__/"$commacontent"/ if $commacontent; - $left =~ s/__X__/"$commacontent"/ if $commacontent; - warn "node : $left / $operator / $right\n" if $DEBUG; - my $leftresult = NZanalyse( $left, $server ); - my $rightresult = NZanalyse( $right, $server ); - warn " leftresult : $leftresult" if $DEBUG; - warn " rightresult : $rightresult" if $DEBUG; - # OK, we have the results for right and left part of the query - # depending of operand, intersect, union or exclude both lists - # to get a result list - if ( $operator eq ' and ' ) { - return NZoperatorAND($leftresult,$rightresult); - } - elsif ( $operator eq ' or ' ) { - - # just merge the 2 strings - return $leftresult . $rightresult; - } - elsif ( $operator eq ' not ' ) { - return NZoperatorNOT($leftresult,$rightresult); - } - else { - -# this error is impossible, because of the regexp that isolate the operand, but just in case... - die "error : operand unknown : $operator for $string"; - } - - # it's a leaf, do the real SQL query and return the result - } - else { - $string =~ s/__X__/"$commacontent"/ if $commacontent; - $string =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|&|\+|\*|\// /g; - #remove trailing blank at the beginning - $string =~ s/^ //g; - warn "leaf:$string" if $DEBUG; - - # parse the string in in operator/operand/value again - my $left = ""; - my $operator = ""; - my $right = ""; - if ($string =~ /(.*)(>=|<=)(.*)/) { - $left = $1; - $operator = $2; - $right = $3; - } else { - $left = $string; - } -# warn "handling leaf... left:$left operator:$operator right:$right" -# if $DEBUG; - unless ($operator) { - if ($string =~ /(.*)(>|<|=)(.*)/) { - $left = $1; - $operator = $2; - $right = $3; - warn - "handling unless (operator)... left:$left operator:$operator right:$right" - if $DEBUG; - } else { - $left = $string; - } - } - my $results; - -# strip adv, zebra keywords, currently not handled in nozebra: wrdl, ext, phr... - $left =~ s/ .*$//; - - # automatic replace for short operators - $left = 'title' if $left =~ '^ti$'; - $left = 'author' if $left =~ '^au$'; - $left = 'publisher' if $left =~ '^pb$'; - $left = 'subject' if $left =~ '^su$'; - $left = 'koha-Auth-Number' if $left =~ '^an$'; - $left = 'keyword' if $left =~ '^kw$'; - $left = 'itemtype' if $left =~ '^mc$'; # Fix for Bug 2599 - Search limits not working for NoZebra - warn "handling leaf... left:$left operator:$operator right:$right" if $DEBUG; - my $dbh = C4::Context->dbh; - if ( $operator && $left ne 'keyword' ) { - #do a specific search - $operator = 'LIKE' if $operator eq '=' and $right =~ /%/; - my $sth = $dbh->prepare( -"SELECT biblionumbers,value FROM nozebra WHERE server=? AND indexname=? AND value $operator ?" - ); - warn "$left / $operator / $right\n" if $DEBUG; - - # split each word, query the DB and build the biblionumbers result - #sanitizing leftpart - $left =~ s/^\s+|\s+$//; - foreach ( split / /, $right ) { - my $biblionumbers; - $_ =~ s/^\s+|\s+$//; - next unless $_; - warn "EXECUTE : $server, $left, $_" if $DEBUG; - $sth->execute( $server, $left, $_ ) - or warn "execute failed: $!"; - while ( my ( $line, $value ) = $sth->fetchrow ) { - -# if we are dealing with a numeric value, use only numeric results (in case of >=, <=, > or <) -# otherwise, fill the result - $biblionumbers .= $line - unless ( $right =~ /^\d+$/ && $value =~ /\D/ ); - warn "result : $value " - . ( $right =~ /\d/ ) . "==" - . ( $value =~ /\D/?$line:"" ) if $DEBUG; #= $line"; - } - -# do a AND with existing list if there is one, otherwise, use the biblionumbers list as 1st result list - if ($results) { - warn "NZAND" if $DEBUG; - $results = NZoperatorAND($biblionumbers,$results); - } else { - $results = $biblionumbers; - } - } - } - else { - #do a complete search (all indexes), if index='kw' do complete search too. - my $sth = $dbh->prepare( -"SELECT biblionumbers FROM nozebra WHERE server=? AND value LIKE ?" - ); - - # split each word, query the DB and build the biblionumbers result - foreach ( split / /, $string ) { - next if C4::Context->stopwords->{ uc($_) }; # skip if stopword - warn "search on all indexes on $_" if $DEBUG; - my $biblionumbers; - next unless $_; - $sth->execute( $server, $_ ); - while ( my $line = $sth->fetchrow ) { - $biblionumbers .= $line; - } - -# do a AND with existing list if there is one, otherwise, use the biblionumbers list as 1st result list - if ($results) { - $results = NZoperatorAND($biblionumbers,$results); - } - else { - warn "NEW RES for $_ = $biblionumbers" if $DEBUG; - $results = $biblionumbers; - } - } - } - warn "return : $results for LEAF : $string" if $DEBUG; - return $results; - } - warn "---------\nLeave NZanalyse\n---------" if $DEBUG; -} - -sub NZoperatorAND{ - my ($rightresult, $leftresult)=@_; - - my @leftresult = split /;/, $leftresult; - warn " @leftresult / $rightresult \n" if $DEBUG; - - # my @rightresult = split /;/,$leftresult; - my $finalresult; - -# parse the left results, and if the biblionumber exist in the right result, save it in finalresult -# the result is stored twice, to have the same weight for AND than OR. -# example : TWO : 61,61,64,121 (two is twice in the biblio #61) / TOWER : 61,64,130 -# result : 61,61,61,61,64,64 for two AND tower : 61 has more weight than 64 - foreach (@leftresult) { - my $value = $_; - my $countvalue; - ( $value, $countvalue ) = ( $1, $2 ) if ($value=~/(.*)-(\d+)$/); - if ( $rightresult =~ /\Q$value\E-(\d+);/ ) { - $countvalue = ( $1 > $countvalue ? $countvalue : $1 ); - $finalresult .= - "$value-$countvalue;$value-$countvalue;"; - } - } - warn "NZAND DONE : $finalresult \n" if $DEBUG; - return $finalresult; -} - -sub NZoperatorOR{ - my ($rightresult, $leftresult)=@_; - return $rightresult.$leftresult; -} - -sub NZoperatorNOT{ - my ($leftresult, $rightresult)=@_; - - my @leftresult = split /;/, $leftresult; - - # my @rightresult = split /;/,$leftresult; - my $finalresult; - foreach (@leftresult) { - my $value=$_; - $value=$1 if $value=~m/(.*)-\d+$/; - unless ($rightresult =~ "$value-") { - $finalresult .= "$_;"; - } - } - return $finalresult; -} - -=head2 NZorder - - $finalresult = NZorder($biblionumbers, $ordering,$results_per_page,$offset); - - TODO :: Description - -=cut - -sub NZorder { - my ( $biblionumbers, $ordering, $results_per_page, $offset ) = @_; - warn "biblionumbers = $biblionumbers and ordering = $ordering\n" if $DEBUG; - - # order title asc by default - # $ordering = '1=36 dbh; - - # - # order by POPULARITY - # - if ( $ordering =~ /popularity/ ) { - my %result; - my %popularity; - - # popularity is not in MARC record, it's builded from a specific query - my $sth = - $dbh->prepare("select sum(issues) from items where biblionumber=?"); - foreach ( split /;/, $biblionumbers ) { - my ( $biblionumber, $title ) = split /,/, $_; - $result{$biblionumber} = GetMarcBiblio($biblionumber); - $sth->execute($biblionumber); - my $popularity = $sth->fetchrow || 0; - -# hint : the key is popularity.title because we can have -# many results with the same popularity. In this case, sub-ordering is done by title -# we also have biblionumber to avoid bug for 2 biblios with the same title & popularity -# (un-frequent, I agree, but we won't forget anything that way ;-) - $popularity{ sprintf( "%10d", $popularity ) . $title - . $biblionumber } = $biblionumber; - } - - # sort the hash and return the same structure as GetRecords (Zebra querying) - my $result_hash; - my $numbers = 0; - if ( $ordering eq 'popularity_dsc' ) { # sort popularity DESC - foreach my $key ( sort { $b cmp $a } ( keys %popularity ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = - $result{ $popularity{$key} }->as_usmarc(); - } - } - else { # sort popularity ASC - foreach my $key ( sort ( keys %popularity ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = - $result{ $popularity{$key} }->as_usmarc(); - } - } - my $finalresult = (); - $result_hash->{'hits'} = $numbers; - $finalresult->{'biblioserver'} = $result_hash; - return $finalresult; - - # - # ORDER BY author - # - } - elsif ( $ordering =~ /author/ ) { - my %result; - foreach ( split /;/, $biblionumbers ) { - my ( $biblionumber, $title ) = split /,/, $_; - my $record = GetMarcBiblio($biblionumber); - my $author; - if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { - $author = $record->subfield( '200', 'f' ); - $author = $record->subfield( '700', 'a' ) unless $author; - } - else { - $author = $record->subfield( '100', 'a' ); - } - -# hint : the result is sorted by title.biblionumber because we can have X biblios with the same title -# and we don't want to get only 1 result for each of them !!! - $result{ $author . $biblionumber } = $record; - } - - # sort the hash and return the same structure as GetRecords (Zebra querying) - my $result_hash; - my $numbers = 0; - if ( $ordering eq 'author_za' || $ordering eq 'author_dsc' ) { # sort by author desc - foreach my $key ( sort { $b cmp $a } ( keys %result ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = - $result{$key}->as_usmarc(); - } - } - else { # sort by author ASC - foreach my $key ( sort ( keys %result ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = - $result{$key}->as_usmarc(); - } - } - my $finalresult = (); - $result_hash->{'hits'} = $numbers; - $finalresult->{'biblioserver'} = $result_hash; - return $finalresult; - - # - # ORDER BY callnumber - # - } - elsif ( $ordering =~ /callnumber/ ) { - my %result; - foreach ( split /;/, $biblionumbers ) { - my ( $biblionumber, $title ) = split /,/, $_; - my $record = GetMarcBiblio($biblionumber); - my $callnumber; - my $frameworkcode = GetFrameworkCode($biblionumber); - my ( $callnumber_tag, $callnumber_subfield ) = GetMarcFromKohaField( 'items.itemcallnumber', $frameworkcode); - ( $callnumber_tag, $callnumber_subfield ) = GetMarcFromKohaField('biblioitems.callnumber', $frameworkcode) - unless $callnumber_tag; - if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { - $callnumber = $record->subfield( '200', 'f' ); - } else { - $callnumber = $record->subfield( '100', 'a' ); - } - -# hint : the result is sorted by title.biblionumber because we can have X biblios with the same title -# and we don't want to get only 1 result for each of them !!! - $result{ $callnumber . $biblionumber } = $record; - } - - # sort the hash and return the same structure as GetRecords (Zebra querying) - my $result_hash; - my $numbers = 0; - if ( $ordering eq 'call_number_dsc' ) { # sort by title desc - foreach my $key ( sort { $b cmp $a } ( keys %result ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = - $result{$key}->as_usmarc(); - } - } - else { # sort by title ASC - foreach my $key ( sort { $a cmp $b } ( keys %result ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = - $result{$key}->as_usmarc(); - } - } - my $finalresult = (); - $result_hash->{'hits'} = $numbers; - $finalresult->{'biblioserver'} = $result_hash; - return $finalresult; - } - elsif ( $ordering =~ /pubdate/ ) { #pub year - my %result; - foreach ( split /;/, $biblionumbers ) { - my ( $biblionumber, $title ) = split /,/, $_; - my $record = GetMarcBiblio($biblionumber); - my ( $publicationyear_tag, $publicationyear_subfield ) = - GetMarcFromKohaField( 'biblioitems.publicationyear', '' ); - my $publicationyear = - $record->subfield( $publicationyear_tag, - $publicationyear_subfield ); - -# hint : the result is sorted by title.biblionumber because we can have X biblios with the same title -# and we don't want to get only 1 result for each of them !!! - $result{ $publicationyear . $biblionumber } = $record; - } - - # sort the hash and return the same structure as GetRecords (Zebra querying) - my $result_hash; - my $numbers = 0; - if ( $ordering eq 'pubdate_dsc' ) { # sort by pubyear desc - foreach my $key ( sort { $b cmp $a } ( keys %result ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = - $result{$key}->as_usmarc(); - } - } - else { # sort by pub year ASC - foreach my $key ( sort ( keys %result ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = - $result{$key}->as_usmarc(); - } - } - my $finalresult = (); - $result_hash->{'hits'} = $numbers; - $finalresult->{'biblioserver'} = $result_hash; - return $finalresult; - - # - # ORDER BY title - # - } - elsif ( $ordering =~ /title/ ) { - -# the title is in the biblionumbers string, so we just need to build a hash, sort it and return - my %result; - foreach ( split /;/, $biblionumbers ) { - my ( $biblionumber, $title ) = split /,/, $_; - -# hint : the result is sorted by title.biblionumber because we can have X biblios with the same title -# and we don't want to get only 1 result for each of them !!! -# hint & speed improvement : we can order without reading the record -# so order, and read records only for the requested page ! - $result{ $title . $biblionumber } = $biblionumber; - } - - # sort the hash and return the same structure as GetRecords (Zebra querying) - my $result_hash; - my $numbers = 0; - if ( $ordering eq 'title_az' ) { # sort by title desc - foreach my $key ( sort ( keys %result ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = $result{$key}; - } - } - else { # sort by title ASC - foreach my $key ( sort { $b cmp $a } ( keys %result ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = $result{$key}; - } - } - - # limit the $results_per_page to result size if it's more - $results_per_page = $numbers - 1 if $numbers < $results_per_page; - - # for the requested page, replace biblionumber by the complete record - # speed improvement : avoid reading too much things - for ( - my $counter = $offset ; - $counter <= $offset + $results_per_page ; - $counter++ - ) - { - $result_hash->{'RECORDS'}[$counter] = - GetMarcBiblio( $result_hash->{'RECORDS'}[$counter] )->as_usmarc; - } - my $finalresult = (); - $result_hash->{'hits'} = $numbers; - $finalresult->{'biblioserver'} = $result_hash; - return $finalresult; - } - else { - -# -# order by ranking -# -# we need 2 hashes to order by ranking : the 1st one to count the ranking, the 2nd to order by ranking - my %result; - my %count_ranking; - foreach ( split /;/, $biblionumbers ) { - my ( $biblionumber, $title ) = split /,/, $_; - $title =~ /(.*)-(\d)/; - - # get weight - my $ranking = $2; - -# note that we + the ranking because ranking is calculated on weight of EACH term requested. -# if we ask for "two towers", and "two" has weight 2 in biblio N, and "towers" has weight 4 in biblio N -# biblio N has ranking = 6 - $count_ranking{$biblionumber} += $ranking; - } - -# build the result by "inverting" the count_ranking hash -# hing : as usual, we don't order by ranking only, to avoid having only 1 result for each rank. We build an hash on concat(ranking,biblionumber) instead -# warn "counting"; - foreach ( keys %count_ranking ) { - $result{ sprintf( "%10d", $count_ranking{$_} ) . '-' . $_ } = $_; - } - - # sort the hash and return the same structure as GetRecords (Zebra querying) - my $result_hash; - my $numbers = 0; - foreach my $key ( sort { $b cmp $a } ( keys %result ) ) { - $result_hash->{'RECORDS'}[ $numbers++ ] = $result{$key}; - } - - # limit the $results_per_page to result size if it's more - $results_per_page = $numbers - 1 if $numbers < $results_per_page; - - # for the requested page, replace biblionumber by the complete record - # speed improvement : avoid reading too much things - for ( - my $counter = $offset ; - $counter <= $offset + $results_per_page ; - $counter++ - ) - { - $result_hash->{'RECORDS'}[$counter] = - GetMarcBiblio( $result_hash->{'RECORDS'}[$counter] )->as_usmarc - if $result_hash->{'RECORDS'}[$counter]; - } - my $finalresult = (); - $result_hash->{'hits'} = $numbers; - $finalresult->{'biblioserver'} = $result_hash; - return $finalresult; - } -} =head2 enabled_staff_search_views diff --git a/INSTALL.fedora7 b/INSTALL.fedora7 index 509b848..aa0f97f 100644 --- a/INSTALL.fedora7 +++ b/INSTALL.fedora7 @@ -1169,7 +1169,6 @@ MySQL> show tables; | matchpoint_components | | matchpoints | | notifys | -| nozebra | | opac_news | | overduerules | | printers | @@ -1258,7 +1257,7 @@ Connect to Koha: HYPERLINK "http://localhost:8080/" http://localhost:8080 and us -- A Phase 3, click on Install the basic settings (screen 1), select the declination Marc (Unimarc_complet in our Where Unimarc_lecture_pub; screen 2), select default settings and then click on Import (only settings obligat oires are checked by default; screen 3); --- The screen 4 summarizes what has been imported, while low demand to opt for a configuration Zebra (our choice) or NoZebra; +-- The screen 4 summarizes what has been imported; -- Finally, the screen 5 indicates the end of the installation; then you just have to click Finish. Complements diff --git a/about.pl b/about.pl index 3c641b3..96a8b5a 100755 --- a/about.pl +++ b/about.pl @@ -61,7 +61,6 @@ $apacheVersion = (`/usr/sbin/apache2 -V`)[0] unless $apacheVersion; my $zebraVersion = `zebraidx -V`; # Additional system information for warnings -my $prefNoZebra = C4::Context->preference('nozebra'); my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities'); my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities'); my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) ); @@ -83,7 +82,6 @@ $template->param( mysqlVersion => $mysqlVersion, apacheVersion => $apacheVersion, zebraVersion => $zebraVersion, - prefNoZebra => $prefNoZebra, prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities, prefAutoCreateAuthorities => $prefAutoCreateAuthorities, warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities, diff --git a/catalogue/search.pl b/catalogue/search.pl index 680f837..8624b3b 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -517,18 +517,10 @@ my $facets; # this object stores the faceted results that display on the left-ha my @results_array; my $results_hashref; -if (C4::Context->preference('NoZebra')) { - $query=~s/yr(:|=)\s*([\d]{1,4})-([\d]{1,4})/(yr>=$2 and yr<=$3)/g; - $simple_query=~s/yr\s*(:|=)([\d]{1,4})-([\d]{1,4})/(yr>=$2 and yr<=$3)/g; - # warn $query; - eval { - ($error, $results_hashref, $facets) = NZgetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan); - }; -} else { - eval { - ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan); - }; -} +eval { + ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan); +}; + # This sorts the facets into alphabetical order if ($facets) { foreach my $f (@$facets) { diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 221c4e4..4872a1f 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1378,20 +1378,6 @@ CREATE TABLE `notifys` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- --- Table structure for table `nozebra` --- - -DROP TABLE IF EXISTS `nozebra`; -CREATE TABLE `nozebra` ( - `server` varchar(20) NOT NULL, - `indexname` varchar(40) NOT NULL, - `value` varchar(250) NOT NULL, - `biblionumbers` longtext NOT NULL, - KEY `indexname` (`server`,`indexname`), - KEY `value` (`server`,`value`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- -- Table structure for table `oai_sets` -- diff --git a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql b/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql index 5424c7d..8816bae 100644 --- a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql +++ b/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql @@ -32,5 +32,3 @@ UPDATE systempreferences SET value = '1' WHERE variable = 'patronimages'; UPDATE systempreferences SET value = '#200|

Заглавие: |{200a}{. 200c}{ : 200e}{200d}{. 200h}{. 200i}|

\r\n#500||{500a}{. 500i}{. 500h}{. 500m}{. 500q}{. 500k}
|\r\n#517||{517a}{ : 517e}{. 517h}{, 517i}
|\r\n#541||{541a}{ : 541e}
|\r\n#200||
|\r\n#700|| {700c}{ 700b}{ 700a}{ 700d}{ (700f)}{. 7004}
|\r\n#701|| {701c}{ 701b}{ 701a}{ 701d}{ (701f)}{. 7014}
|\r\n#702|| {702c}{ 702b}{ 702a}{ 702d}{ (702f)}{. 7024}
|\r\n#710|| {710a}{ (710c)}{. 710b}{ : 710d}{ ; 710f}{ ; 710e}
|\r\n#711|| {711a}{ (711c)}{. 711b}{ : 711d}{ ; 711f}{ ; 711e}
|\r\n#712|| {712a}{ (712c)}{. 712b}{ : 712d}{ ; 712f}{ ; 712e}
|\r\n#210||{ 210a}
|\r\n#210||{ 210c}
|\r\n#210||{ 210d}
|\r\n#215||{215a}{ : 215c}{ ; 215d}{ + 215e}|
\r\n#225|| { (225a}{ = 225d}{ : 225e}{. 225h}{. 225i}{ / 225f}{, 225x}{ ; 225v}|)
\r\n#200||
|\r\n#600||{ 600c}{ 600b}{ 600a}{ 600d}{ (600f)} {-- 600x }{-- 600z }{-- 600y}
|\r\n#604||{ 604a}{. 604t}
|\r\n#601||{ 601a}{ (601c)}{. 601b}{ : 601d} { ; 601f}{ ; 601e}{ -- 601x }{-- 601z }{-- 601y}
|\r\n#605||{ 605a}{. 605i}{. 605h}{. 605k}{. 605m}{. 605q} {-- 605x }{-- 605z }{-- 605y }{-- 605l}
|\r\n#606||xx{ 606a}{-- 606x }{-- 606z }{606y }
|\r\n#607||{ 607a}{-- 607x}{-- 607z}{-- 607y}
|\r\n#010||{010a}|
\r\n#011||{011a}|
\r\n#200|||
\r\n#300||{300a}|
\r\n#320||{320a}|
\r\n#327||{327a}|
\r\n#328||{328a}|
\r\n#200||

Экземпляры

|\r\n#200|||\r\n#995|||\r\n#200|||
РасположениеCote
{995e}   {995k}
' WHERE variable = 'ISBD'; -UPDATE systempreferences SET value = '\'title\' =>\r\n\'200a,200c,200d,200e,225a,225d,225e,225f,225h,225i,225v,500*,501*,503*,510*,\r\n512*,513*,514*,515*,516*,517*,518*,519*,520*,530*,531*,532*,540*,541*,545*,6\r\n04t,610t,605a\',\r\n\'author\'=>\'200f,600a,601a,604a,700a,700b,700c,700d,700a,701b,701c,701d,702a,\r\n702b,702c,702d,710a,710b,710c,710d,711a,711b,711c,711d,712a,712b,712c,712d\',\r\n\'se\'=>\'225a\',\r\n \'isbn\' => \'010a\',\r\n \'issn\' => \'011a\',\r\n \'biblionumber\' =>\'0909\',\r\n \'itemtype\' => \'200b\',\r\n \'language\' => \'101a\',\r\n \'pl\' => \'210a\',\r\n \'publisher\' => \'210c\',\r\n \'date\' => \'210d\',\r\n \'note\' =>\r\n\'300a,301a,302a,303a,304a,305a,306az,307a,308a,309a,310a,311a,312a,313a,314a\r\n,315a,316a,317a,318a,319a,320a,321a,322a,323a,324a,325a,326a,327a,328a,330a,\r\n332a,333a,336a,337a,345a\',\r\n \'an\' => \'6009,6019,6069,6109,6079\',\r\n \'su\' => \'600a,601a,606a,610a,607a,608a\',\r\n\'lcn\'=>\'686a,995k\',\r\n\'yr\'=>\'210d\',\r\n \'mt\' => \'200b\',\r\n \'dewey\' => \'676a\',\r\n \'host-item\' => \'995b,995c\',\'keyword\' => \'200*,600*,700*,400*,210*\' ' WHERE variable = 'NoZebraIndexes'; - diff --git a/installer/data/mysql/ru-RU/mandatory/system_preferences_optimal_values_insert_only.sql b/installer/data/mysql/ru-RU/mandatory/system_preferences_optimal_values_insert_only.sql index 298c00f..eb34a8d 100644 --- a/installer/data/mysql/ru-RU/mandatory/system_preferences_optimal_values_insert_only.sql +++ b/installer/data/mysql/ru-RU/mandatory/system_preferences_optimal_values_insert_only.sql @@ -47,8 +47,6 @@ UPDATE systempreferences SET value='942hv' WHERE variable='itemcallnumber'; UPDATE systempreferences SET value='UNIMARC' WHERE variable='marcflavour'; -UPDATE systempreferences SET value='\'title\' =>\r\n\'200a,200c,200d,200e,225a,225d,225e,225f,225h,225i,225v,500*,501*,503*,510*,\r\n512*,513*,514*,515*,516*,517*,518*,519*,520*,530*,531*,532*,540*,541*,545*,6\r\n04t,610t,605a\',\r\n\'author\'=>\'200f,600a,601a,604a,700a,700b,700c,700d,700a,701b,701c,701d,702a,\r\n702b,702c,702d,710a,710b,710c,710d,711a,711b,711c,711d,712a,712b,712c,712d\',\r\n\'se\'=>\'225a\',\r\n \'isbn\' => \'010a\',\r\n \'issn\' => \'011a\',\r\n \'biblionumber\' =>\'0909\',\r\n \'itemtype\' => \'200b\',\r\n \'language\' => \'101a\',\r\n \'pl\' => \'210a\',\r\n \'publisher\' => \'210c\',\r\n \'date\' => \'210d\',\r\n \'note\' =>\r\n\'300a,301a,302a,303a,304a,305a,306az,307a,308a,309a,310a,311a,312a,313a,314a\r\n,315a,316a,317a,318a,319a,320a,321a,322a,323a,324a,325a,326a,327a,328a,330a,\r\n332a,333a,336a,337a,345a\',\r\n \'an\' => \'6009,6019,6069,6109,6079\',\r\n \'su\' => \'600a,601a,606a,610a,607a,608a\',\r\n\'lcn\'=>\'686a,995k\',\r\n\'yr\'=>\'210d\',\r\n \'mt\' => \'200b\',\r\n \'dewey\' => \'676a\',\r\n \'host-item\' => \'995b,995c\',\'keyword\' => \'200*,600*,700*,400*,210*\' ' WHERE variable='NoZebraIndexes'; - -- Circulation - Оборот -- I18N/L10N diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index e3966ce..ae298ed 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -115,7 +115,6 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('z3950NormalizeAuthor',0,'If ON, Personal Name Authorities will replace authors in biblio.author','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ReservesNeedReturns',1,'If ON, a hold placed on an item available in this library must be checked-in, otherwise, a hold on a specific item, that is in the library & available is considered available','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('DebugLevel',2,'Define the level of debugging information sent to the browser when errors are encountered (set to 0 in production). 0=none, 1=some, 2=most','0|1|2','Choice'); -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('NoZebra',0,'If ON, Zebra indexing is turned off, simpler setup, but slower searches. WARNING: using NoZebra on even modest sized collections is very slow.','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SessionStorage','mysql','Use database or a temporary file for storing session data','mysql|Pg|tmp','Choice'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('CircAutocompl',1,'If ON, autocompletion is enabled for the Circulation input',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('RoutingSerials',1,'If ON, serials routing is enabled',NULL,'YesNo'); @@ -174,8 +173,6 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACBaseURL',NULL,'Specify the Base URL of the OPAC, e.g., opac.mylibrary.com, the http:// will be added automatically by Koha.',NULL,'Free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('language','en','Set the default language in the staff client.',NULL,'Languages'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryAutoTruncate',1,'If ON, query truncation is enabled by default',NULL,'YesNo'); -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryRemoveStopwords',0,'If ON, stopwords listed in the Administration area will be removed from queries',NULL,'YesNo'); -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NoZebraIndexes','\'title\' => \'130a,210a,222a,240a,243a,245a,245b,246a,246b,247a,247b,250a,250b,440a,830a\',\r\n\'author\' => \'100a,100b,100c,100d,110a,111a,111b,111c,111d,245c,700a,710a,711a,800a,810a,811a\',\r\n\'isbn\' => \'020a\',\r\n\'issn\' => \'022a\',\r\n\'lccn\' => \'010a\',\r\n\'biblionumber\' => \'999c\',\r\n\'itemtype\' => \'942c\',\r\n\'publisher\' => \'260b\',\r\n\'date\' => \'260c\',\r\n\'note\' => \'500a, 501a,504a,505a,508a,511a,518a,520a,521a,522a,524a,526a,530a,533a,538a,541a,546a,555a,556a,562a,563a,583a,585a,582a\',\r\n\'subject\' => \'600*,610*,611*,630*,650*,651*,653*,654*,655*,662*,690*\',\r\n\'dewey\' => \'082\',\r\n\'bc\' => \'952p\',\r\n\'callnum\' => \'952o\',\r\n\'an\' => \'6009,6109,6119\',\r\n\'homebranch\' => \'952a,952c\'','Enter a specific hash for NoZebra indexes. Enter : \'indexname\' => \'100a,245a,500*\',\'index2\' => \'...\'','70|10','Textarea'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacRenewalAllowed',0,'If ON, users can renew their issues directly from their OPAC account',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('PatronsPerPage','20','Number of Patrons Per Page displayed by default','20','Integer'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('HomeOrHoldingBranch','holdingbranch','Used by Circulation to determine which branch of an item to check with independent branches on, and by search to determine which branch to choose for availability ','holdingbranch|homebranch','Choice'); diff --git a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql b/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql index 396e059..83e320c 100644 --- a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql +++ b/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql @@ -31,31 +31,3 @@ UPDATE systempreferences SET value = 'Тут будуть важливі пос UPDATE systempreferences SET value = '1' WHERE variable = 'patronimages'; UPDATE systempreferences SET value = '#200|

Заголовок: |{200a}{. 200c}{ : 200e}{200d}{. 200h}{. 200i}|

\r\n#500||{500a}{. 500i}{. 500h}{. 500m}{. 500q}{. 500k}
|\r\n#517||{517a}{ : 517e}{. 517h}{, 517i}
|\r\n#541||{541a}{ : 541e}
|\r\n#200||
|\r\n#700|| {700c}{ 700b}{ 700a}{ 700d}{ (700f)}{. 7004}
|\r\n#701|| {701c}{ 701b}{ 701a}{ 701d}{ (701f)}{. 7014}
|\r\n#702|| {702c}{ 702b}{ 702a}{ 702d}{ (702f)}{. 7024}
|\r\n#710|| {710a}{ (710c)}{. 710b}{ : 710d}{ ; 710f}{ ; 710e}
|\r\n#711|| {711a}{ (711c)}{. 711b}{ : 711d}{ ; 711f}{ ; 711e}
|\r\n#712|| {712a}{ (712c)}{. 712b}{ : 712d}{ ; 712f}{ ; 712e}
|\r\n#210||{ 210a}
|\r\n#210||{ 210c}
|\r\n#210||{ 210d}
|\r\n#215||{215a}{ : 215c}{ ; 215d}{ + 215e}|
\r\n#225|| { (225a}{ = 225d}{ : 225e}{. 225h}{. 225i}{ / 225f}{, 225x}{ ; 225v}|)
\r\n#200||
|\r\n#600||{ 600c}{ 600b}{ 600a}{ 600d}{ (600f)} {-- 600x }{-- 600z }{-- 600y}
|\r\n#604||{ 604a}{. 604t}
|\r\n#601||{ 601a}{ (601c)}{. 601b}{ : 601d} { ; 601f}{ ; 601e}{ -- 601x }{-- 601z }{-- 601y}
|\r\n#605||{ 605a}{. 605i}{. 605h}{. 605k}{. 605m}{. 605q} {-- 605x }{-- 605z }{-- 605y }{-- 605l}
|\r\n#606||xx{ 606a}{-- 606x }{-- 606z }{606y }
|\r\n#607||{ 607a}{-- 607x}{-- 607z}{-- 607y}
|\r\n#010||{010a}|
\r\n#011||{011a}|
\r\n#200|||
\r\n#300||{300a}|
\r\n#320||{320a}|
\r\n#327||{327a}|
\r\n#328||{328a}|
\r\n#200||

Примірники

|\r\n#200|||\r\n#995|||\r\n#200|||
МісцезнаходженняCote
{995e}   {995k}
' WHERE variable = 'ISBD'; - -UPDATE systempreferences SET value = " - 'title' => '200a,200c,200d,200e,225a,225d,225e,225f,225h,225i,225v,500*,501*,503*,510*,512*,513*,514*,515*,516*,517*,518*,519*,520*,530*,531*,532*,540*,541*,545*,604t,610t,605a', - 'author' => '200f,600a,601a,604a,700a,700b,700c,700d,700a,701b,701c,701d,702a,702b,702c,702d,710a,710b,710c,710d,711a,711b,711c,711d,712a,712b,712c,712d', - 'se' => '225a', - 'isbn' => '010a', - 'issn' => '011a', - 'biblionumber' => '9999', - 'itemtype' => '200b,942c,952y', - 'language' => '101a', - 'pl' => '210a', - 'publisher' => '210c', - 'date' => '210d', - 'note' => '300a,301a,302a,303a,304a,305a,306az,307a,308a,309a,310a,311a,312a,313a,314a,315a,316a,317a,318a,319a,320a,321a,322a,323a,324a,325a,326a,327a,328a,330a,332a,333a,336a,337a,345a', - 'Koha-Auth-Number' => '6009,6019,6029,6039,6049,6059,6069,6109,7009,7019,7029,7109,7119,7129', - 'subject' => '600*,601*,606*,610*', - 'an' => '6009,6019,6069,6109,6079', - 'su' => '600a,601a,606a,610a,607a,608a', - 'lcn' => '686a,952o', - 'yr' => '210d', - 'mt' => '200b', - 'dewey' => '676a', - 'bc' => '952p', - 'callnum' => '952o', - 'homebranch' => '952a,952c', - 'host-item' => '992b,992c', - 'keyword' => '200*,600*,700*,400*,210*' -" WHERE variable = 'NoZebraIndexes'; diff --git a/installer/data/mysql/uk-UA/mandatory/system_preferences_optimal_values_insert_only.sql b/installer/data/mysql/uk-UA/mandatory/system_preferences_optimal_values_insert_only.sql index c6b60f6..af0299b 100644 --- a/installer/data/mysql/uk-UA/mandatory/system_preferences_optimal_values_insert_only.sql +++ b/installer/data/mysql/uk-UA/mandatory/system_preferences_optimal_values_insert_only.sql @@ -47,34 +47,6 @@ UPDATE systempreferences SET value='942hv' WHERE variable='itemcallnumber'; UPDATE systempreferences SET value='UNIMARC' WHERE variable='marcflavour'; -UPDATE systempreferences SET value=" - 'title' => '200a,200c,200d,200e,225a,225d,225e,225f,225h,225i,225v,500*,501*,503*,510*,512*,513*,514*,515*,516*,517*,518*,519*,520*,530*,531*,532*,540*,541*,545*,604t,610t,605a', - 'author' => '200f,600a,601a,604a,700a,700b,700c,700d,700a,701b,701c,701d,702a,702b,702c,702d,710a,710b,710c,710d,711a,711b,711c,711d,712a,712b,712c,712d', - 'se' => '225a', - 'isbn' => '010a', - 'issn' => '011a', - 'biblionumber' => '9999', - 'itemtype' => '200b,942c,952y', - 'language' => '101a', - 'pl' => '210a', - 'publisher' => '210c', - 'date' => '210d', - 'note' => '300a,301a,302a,303a,304a,305a,306az,307a,308a,309a,310a,311a,312a,313a,314a,315a,316a,317a,318a,319a,320a,321a,322a,323a,324a,325a,326a,327a,328a,330a,332a,333a,336a,337a,345a', - 'Koha-Auth-Number' => '6009,6019,6029,6039,6049,6059,6069,6109,7009,7019,7029,7109,7119,7129', - 'subject' => '600*,601*,606*,610*', - 'an' => '6009,6019,6069,6109,6079', - 'su' => '600a,601a,606a,610a,607a,608a', - 'lcn' => '686a,952o', - 'yr' => '210d', - 'mt' => '200b', - 'dewey' => '676a', - 'bc' => '952p', - 'callnum' => '952o', - 'homebranch' => '952a,952c', - 'host-item' => '992b,992c', - 'keyword' => '200*,600*,700*,400*,210*' -" WHERE variable='NoZebraIndexes'; - -- Circulation - Обіг -- I18N/L10N diff --git a/installer/install.pl b/installer/install.pl index d9feac4..58388cb 100755 --- a/installer/install.pl +++ b/installer/install.pl @@ -189,7 +189,6 @@ elsif ( $step && $step == 3 ) { } elsif ( $op && $op eq 'finish' ) { $installer->set_version_syspref(); - $installer->set_indexing_engine(0); # use Zebra # Installation is finished. # We just deny anybody access to install diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc index b207da5..91878bf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc @@ -60,7 +60,6 @@
Additional parameters