<<

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,$itemtypes,
        $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.

_handle_exploding_index

    my $query = _handle_exploding_index($index, $term)

Callback routine to generate the search for "exploding" indexes (i.e. those indexes which are turned into multiple or-connected searches based on authority data).

parseQuery

    ( $operators, $operands, $indexes, $limits,
      $sort_by, $scan, $lang ) =
            buildQuery ( $operators, $operands, $indexes, $limits, $sort_by, $scan, $lang);

Shim function to ease the transition from buildQuery to a new QueryParser. This function is called at the beginning of buildQuery, and modifies buildQuery's input. If it can handle the input, it returns a query that buildQuery will not try to parse.

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

Format results in a form suitable for passing to the template

SearchAcquisitions Search for acquisitions

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 and value, 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 is 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

_ZOOM_event_loop

    _ZOOM_event_loop(\@zconns, \@results, sub {
        my ( $i, $size ) = @_;
        ....
    } );

Processes a ZOOM event loop and passes control to a closure for processing the results, and destroying the resultsets.

new_record_from_zebra

Given raw data from a Zebra result set, return a MARC::Record object

This helper function is needed to take into account all the involved system preferences and configuration variables to properly create the MARC::Record object.

If we are using GRS-1, then the raw data we get from Zebra should be USMARC data. If we are using DOM, then it has to be MARCXML.

AUTHOR

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

<<