<<

NAME

Koha::QueryParser::Driver::PQF - QueryParser driver for PQF

SYNOPSIS

    use Koha::QueryParser::Driver::PQF;
    my $QParser = Koha::QueryParser::Driver::PQF->new(%args);

DESCRIPTION

Main entrypoint into the QueryParser PQF driver. PQF is the Prefix Query Language, the syntax used to serialize Z39.50 queries.

ACCESSORS

In order to simplify Bib-1 attribute mapping, this driver uses Class::Accessor for accessing the following maps:

bib1_field_map - search class/field Bib-1 mappings
bib1_modifier_map - search modifier mappings
bib1_filter_map - search filter mappings
bib1_relevance_bump_map - relevance bump mappings

FUNCTIONS

get

Overridden accessor method for Class::Accessor. (Do not call directly)

set

Overridden mutator method for Class::Accessor. (Do not call directly)

add_bib1_field_map

    $QParser->add_bib1_field_map($class => $field => $server => \%attributes);

    $QParser->add_bib1_field_map('author' => 'personal' => 'biblioserver' =>
                                    { '1' => '1003' });

Adds a search field<->bib1 attribute mapping for the specified server. The %attributes hash contains maps Bib-1 Attributes to the appropropriate values. Not all attributes must be specified.

add_bib1_modifier_map

    $QParser->add_bib1_modifier_map($name => $server => \%attributes);

    $QParser->add_bib1_modifier_map('ascending' => 'biblioserver' =>
                                    { '7' => '1' });

Adds a search modifier<->bib1 attribute mapping for the specified server. The %attributes hash contains maps Bib-1 Attributes to the appropropriate values. Not all attributes must be specified.

add_bib1_filter_map

    $QParser->add_bib1_filter_map($name => $server => \%attributes);

    $QParser->add_bib1_filter_map('date' => 'biblioserver' =>
                                    { 'callback' => &_my_callback });

Adds a search filter<->bib1 attribute mapping for the specified server. The %attributes hash maps Bib-1 Attributes to the appropropriate values and provides a callback for the filter. Not all attributes must be specified.

add_relevance_bump

    $QParser->add_relevance_bump($class, $field, $server, $multiplier, $active);
    $QParser->add_relevance_bump('title' => 'exact' => 'biblioserver' => 34, 1);

Add a relevance bump to the specified field. When searching for a class without any fields, all the relevance bumps for the specified class will be 'OR'ed together.

target_syntax

    my $pqf = $QParser->target_syntax($server, [$query]);
    my $pqf = $QParser->target_syntax('biblioserver', 'author|personal:smith');
    print $pqf; # assuming all the indexes are configured,
                # prints '@attr 1=1003 @attr 4=6 "smith"'

Transforms the current or specified query into a PQF query string for the specified server.

date_filter_target_callback

    $QParser->add_bib1_filter_map($server, { 'target_syntax_callback' => \&Koha::QueryParser::Driver::PQF::date_filter_target_callback, '1' => 'pubdate' });

Callback for date filters. Note that although the first argument is the QParser object, this is technically not an object-oriented routine. This has no real-world implications.

_map

    return $self->_map('bib1_field_map', $map);

Retrieves or sets a map.

_add_mapping

    return $self->_add_mapping($map, $name, $server, $attributes)

Adds a mapping. Note that this is not used for mappings relating to fields.

_add_field_mapping

    return $self->_add_field_mapping($map, $class, $field, $server, $attributes)

Adds a mapping for field-related data.

bib1_mapping_by_name

    my $attributes = $QParser->bib1_mapping_by_name($type, $name[, $subname], $server);
    my $attributes = $QParser->bib1_mapping_by_name('field', 'author', 'personal', 'biblioserver');
    my $attributes = $QParser->bib1_mapping_by_name('filter', 'pubdate', 'biblioserver');

Retrieve the Bib-1 attribute set associated with the specified mapping.

bib1_mapping_by_attr

    my $field = $QParser->bib1_mapping_by_attr($type, $server, \%attr);
    my $field = $QParser->bib1_mapping_by_attr('field', 'biblioserver', {'1' => '1004'});
    print $field->{'classname'}; # prints "author"
    print $field->{'field'}; # prints "personal"

Retrieve the search field/modifier/filter used for the specified Bib-1 attribute set.

bib1_mapping_by_attr_string

    my $field = $QParser->bib1_mapping_by_attr_string($type, $server, $attr_string);
    my $field = $QParser->bib1_mapping_by_attr_string('field', 'biblioserver', '@attr 1=1004');
    print $field->{'classname'}; # prints "author"
    print $field->{'field'}; # prints "personal"

Retrieve the search field/modifier/filter used for the specified Bib-1 attribute string (i.e. PQF snippet).

clear_all_configuration

    $QParser->clear_all_configuration

Clear all configuration. This is a highly destructive method. You may not want to use it.

clear_all_mappings

    $QParser->clear_all_mappings

Clear all bib-1 mappings.

_canonicalize_field_map

Convert a field map into its canonical form for serialization. Used only for fields and relevance bumps.

_canonicalize_map

Convert a map into its canonical form for serialization. Not used for fields.

serialize_mappings

    my $yaml = $QParser->serialize_mappings;
    my $json = $QParser->serialize_mappings('json');

Serialize Bib-1 mappings to YAML or JSON.

initialize

    $QParser->initialize( { 'bib1_field_mappings' => \%bib1_field_mappings,
                            'search_field_alias_mappings' => \%search_field_alias_mappings,
                            'bib1_modifier_mappings' => \%bib1_modifier_mappings,
                            'bib1_filter_mappings' => \%bib1_filter_mappings,
                            'relevance_bumps' => \%relevance_bumps });

Initialize the QueryParser mapping tables based on the provided configuration. This method was written to play nice with YAML configuration files loaded by load_config.

load_config

  $QParser->load_config($file_name);

Load a YAML file with a parser configuration. The YAML file should match the following format:

    ---
    field_mappings:
      author:
        "":
          aliases:
            - au
          bib1_mapping:
            biblioserver:
              1: 1003
          enabled: 1
          index: ''
          label: ''
        conference:
          aliases:
            - conference
            - cfn
          bib1_mapping:
            biblioserver:
              1: 1006
          enabled: 1
          index: conference
          label: Conference
    filter_mappings:
      acqdate:
        bib1_mapping:
          biblioserver:
            1: Date-of-acquisition
            4: 4
            target_syntax_callback: date_filter_target_callback
        enabled: 1
        label: Acqdate
    modifier_mappings:
      AuthidAsc:
        bib1_mapping:
          authorityserver:
            "": 0
            1: Local-Number
            7: 1
            op: "@or"
        enabled: 1
        label: AuthidAsc
    ...

TEST_SETUP

    $QParser->TEST_SETUP

This routine initializes the QueryParser driver with a reasonable set of defaults. This is intended only for testing. Although such test stubs are generally not included in Koha, this type of test stub is used by other QueryParser implementations, and it seems sensible to maintain consistency as much as possible.

<<