Koha::SearchEngine::Elasticsearch - Base module for things using elasticsearch



The name of the index to use, generally 'biblios' or 'authorities'.



    my $params = $self->get_elasticsearch_params();

This provides a hashref that contains the parameters for connecting to the ElasicSearch servers, in the form:

        'nodes' => ['', 'anotherserver:9200'],
        'index_name' => 'koha_instance_index',

This is configured by the following in the config block in koha-conf.xml:



    my $settings = $self->get_elasticsearch_settings();

This provides the settings provided to elasticsearch when an index is created. These can do things like define tokenisation methods.

A hashref containing the settings is returned.


    my $mappings = $self->get_elasticsearch_mappings();

This provides the mappings that get passed to elasticsearch when an index is created.


        sub {
            my ( $name, $type, $facet, $suggestible, $sort, $marc_type,
                $marc_field )
              = @_;
            return unless $marc_type eq 'marc21';
            print "Data comes from: " . $marc_field . "\n";

This allows you to apply a function to each entry in the elasticsearch mappings table, in order to build the mappings for whatever is needed.

In the provided function, the files are:


The field name for elasticsearch (corresponds to the 'mapping' column in the database.


The type for this value, e.g. 'string'.


True if this value should be facetised. This only really makes sense if the field is understood by the facet processing code anyway.


True if this is a field that a) needs special sort handling, and b) if it should be sorted on. False if a) but not b). Undef if not a). This allows, for example, author to be sorted on but not everything marked with "author" to be included in that sort.


A string that indicates the MARC type that this mapping is for, e.g. 'marc21', 'unimarc', 'normarc'.


A string that describes the MARC field that contains the data to extract. These are of a form suited to Catmandu's MARC fixers.


    die process_error($@);

This parses an Elasticsearch error message and produces a human-readable result from it. This result is probably missing all the useful information that you might want in diagnosing an issue, so the warning is also logged.

Note that currently the resulting message is not internationalised. This will happen eventually by some method or other.


Chris Cormack <chrisc@catalyst.net.nz>
Robin Sheat <robin@catalyst.net.nz>
Jonathan Druart <jonathan.druart@bugs.koha-community.org>