<<

NAME

C4::Search - Functions for searching the Koha catalog.

SYNOPSIS

See opac/opac-search.pl or catalogue/search.pl for example of usage

DESCRIPTION

This module provides searching functions for Koha's bibliographic databases

FUNCTIONS

FindDuplicate

($biblionumber,$biblionumber,$title) = FindDuplicate($record);

This function attempts to find duplicate records using a hard-coded, fairly simplistic algorithm

SimpleSearch

( $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.
Return:
    Returns an array consisting of three elements
    * $error is undefined unless an error is detected
    * $results is a reference to an array of records.
    * $total_hits is the number of hits that would have been returned with no limit

    If an error is returned the two other return elements are undefined. If error itself is undefined
    the other two elements are always defined
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 = @{$marcresults}; my @results;

for my $r ( @{$marcresults} ) { my $marcrecord = MARC::File::USMARC::decode($r); my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,q{});

    #build the iarray of hashs for the template.
    push @results, {
        title           => $biblio->{'title'},
        subtitle        => $biblio->{'subtitle'},
        biblionumber    => $biblio->{'biblionumber'},
        author          => $biblio->{'author'},
        publishercode   => $biblio->{'publishercode'},
        publicationyear => $biblio->{'publicationyear'},
        };

}

$template->param(result=>\@results);

getRecords

( 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.

getIndexes

Return an array with available indexes.

buildQuery

( $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.

searchResults

  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

SearchAcquisitions Search for acquisitions

NZgetRecords

  NZgetRecords has the same API as zera getRecords, even if some parameters are not managed

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.

NZorder

  $finalresult = NZorder($biblionumbers, $ordering,$results_per_page,$offset);

  TODO :: Description

enabled_staff_search_views

%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 );

z3950_search_args

$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) )

GetDistinctValues($field);

$field is a reference to the fields array

AUTHOR

Koha Development Team <http://koha-community.org/>

<<