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' => ['127.0.0.1:9200', 'anotherserver:9200'], 'index_name' => 'koha_instance_index', }
This is configured by the following in the config
block in koha-conf.xml:
<elasticsearch> <server>127.0.0.1:9200</server> <server>anotherserver:9200</server> <index_name>koha_instance</index_name> </elasticsearch>
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.
Get the ES mappings for the given data type or a special mapping case
Receives the same parameters from the $self->_foreach_mapping() dispatcher
$self->_foreach_mapping( 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:
$name
The field name for elasticsearch (corresponds to the 'mapping' column in the database.
$type
The type for this value, e.g. 'string'.
$facet
True if this value should be facetised. This only really makes sense if the field is understood by the facet processing code anyway.
$sort
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.
$marc_type
A string that indicates the MARC type that this mapping is for, e.g. 'marc21', 'unimarc', 'normarc'.
$marc_field
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.
<chrisc@catalyst.net.nz>
<robin@catalyst.net.nz>
<jonathan.druart@bugs.koha-community.org>