C4::Search - Functions for searching the Koha catalog.
See opac/opac-search.pl or catalogue/search.pl for example of usage
This module provides searching functions for Koha's bibliographic databases
($biblionumber,$biblionumber,$title) = FindDuplicate($record);
This function attempts to find duplicate records using a hard-coded, fairly simplistic algorithm
( $error, $results, $total_hits ) = SimpleSearch( $query, $offset, $max_results, [@servers] );
This function provides a simple search API on the bibliographic catalog
input arg:
* $query can be a simple keyword or a complete CCL query * @servers is optional. Defaults to biblioserver as found in koha-conf.xml * $offset - If present, represents the number of records at the beggining to omit. Defaults to 0 * $max_results - if present, determines the maximum number of records to fetch. undef is All. defaults to undef.
Output:
* $error is a empty unless an error is detected * \@results is an array of records. * $total_hits is the number of hits that would have been returned with no limit
usage in the script:
my ( $error, $marcresults, $total_hits ) = SimpleSearch($query);
if (defined $error) { $template->param(query_error => $error); warn "error: ".$error; output_html_with_http_headers $input, $cookie, $template->output; exit; }
my $hits = scalar @$marcresults; my @results;
for my $i (0..$hits) { my %resultsloop; my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]); my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,'');
#build the hash for the template. $resultsloop{title} = $biblio->{'title'}; $resultsloop{subtitle} = $biblio->{'subtitle'}; $resultsloop{biblionumber} = $biblio->{'biblionumber'}; $resultsloop{author} = $biblio->{'author'}; $resultsloop{publishercode} = $biblio->{'publishercode'}; $resultsloop{publicationyear} = $biblio->{'publicationyear'}; push @results, \%resultsloop; }
$template->param(result=>\@results);
( undef, $results_hashref, \@facets_loop ) = getRecords (
$koha_query, $simple_query, $sort_by_ref, $servers_ref, $results_per_page, $offset, $expanded_facet, $branches, $query_type, $scan );
The all singing, all dancing, multi-server, asynchronous, scanning, searching, record nabbing, facet-building
See verbse embedded documentation.
Return an array with available indexes.
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, $limit_desc, $stopwords_removed, $query_type ) = buildQuery ( $operators, $operands, $indexes, $limits, $sort_by, $scan, $lang);
Build queries and limits in CCL, CGI, Human, handle truncation, stemming, field weighting, stopwords, fuzziness, etc.
See verbose embedded documentation.
my @search_results = searchResults($search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults, $hidelostitems);
Format results in a form suitable for passing to the template
NZgetRecords has the same API as zera getRecords, even if some parameters are not managed
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.
$finalresult = NZorder($biblionumbers, $ordering,$results_per_page,$offset); TODO :: Description
%hash = enabled_staff_search_views()
This function returns a hash that contains three flags obtained from the system preferences, used to determine whether a particular staff search results view is enabled.
Output arg:
* $hash{can_view_MARC} is true only if the MARC view is enabled * $hash{can_view_ISBD} is true only if the ISBD view is enabled * $hash{can_view_labeledMARC} is true only if the Labeled MARC view is enabled
usage in the script:
$template->param ( C4::Search::enabled_staff_search_views );
$arrayref = z3950_search_args($matchpoints)
This function returns an array reference that contains the search parameters to be passed to the Z39.50 search script (z3950_search.pl). The array elements are hash refs whose keys are name, value and encvalue, and whose values are the name of a search parameter, the value of that search parameter and the URL encoded value of that parameter.
The search parameter names are lccn, isbn, issn, title, author, dewey and subject.
The search parameter values are obtained from the bibliographic record whose data is in a hash reference in $matchpoints, as returned by Biblio::GetBiblioData().
If $matchpoints is a scalar, it is assumed to be an unnamed query descriptor, e.g. a general purpose search argument. In this case, the returned array contains only entry: the key is 'title' and the value and encvalue are derived from $matchpoints.
If a search parameter value is undefined or empty, it is not included in the returned array.
The returned array reference may be passed directly to the template parameters.
Output arg:
* $array containing hash refs as described above
usage in the script:
$data = Biblio::GetBiblioData($bibno); $template->param ( MYLOOP => C4::Search::z3950_search_args($data) )
*OR*
$template->param ( MYLOOP => C4::Search::z3950_search_args($searchscalar) )
( $countlinked, $countcreated ) = BiblioAddAuthorities($record, $frameworkcode);
this function finds the authorities linked to the biblio * search in the authority DB for the same authid (in $9 of the biblio) * search in the authority DB for the same 001 (in $3 of the biblio in UNIMARC) * search in the authority DB for the same values (exactly) (in all subfields of the biblio) OR adds a new authority record
input arg:
* $record is the MARC record in question (marc blob) * $frameworkcode is the bibliographic framework to use (if it is "" it uses the default framework)
Output arg:
* $countlinked is the number of authorities records that are linked to this authority * $countcreated
BUGS
* I had to add this to Search.pm (instead of the logical Biblio.pm) because of a circular dependency (this sub uses SimpleSearch, and Search.pm uses Biblio.pm)$field
is a reference to the fields array
Koha Development Team <info@koha.org>