<<

NAME

Koha::SearchEngine::Elasticsearch::Indexer - handles adding new records to the index

SYNOPSIS

    my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new(
        { index => Koha::SearchEngine::BIBLIOS_INDEX } );
    $indexer->drop_index();
    $indexer->update_index(\@biblionumbers, \@records);

CONSTANTS

Koha::SearchEngine::Elasticsearch::Indexer::INDEX_STATUS_OK

Represents an index state where index is created and in a working state.

Koha::SearchEngine::Elasticsearch::Indexer::INDEX_STATUS_REINDEX_REQUIRED

Not currently used, but could be useful later, for example if can detect when new field or mapping added.

Koha::SearchEngine::Elasticsearch::Indexer::INDEX_STATUS_RECREATE_REQUIRED

Representings an index state where index needs to be recreated and is not in a working state.

FUNCTIONS

update_index($biblionums, $records)

    try {
        $self->update_index($biblionums, $records);
    } catch {
        die("Something went wrong trying to update index:" .  $_[0]);
    }

Converts MARC::Records $records to Elasticsearch documents and performs an update request for these records on the Elasticsearch index.

$biblionums

Arrayref of biblio numbers for the $records, the order must be the same as and match up with $records.

$records

Arrayref of MARC::Records.

set_index_status_ok

Convenience method for setting index status to INDEX_STATUS_OK.

is_index_status_ok

Convenience method for checking if index status is INDEX_STATUS_OK.

set_index_status_reindex_required

Convenience method for setting index status to INDEX_REINDEX_REQUIRED.

is_index_status_reindex_required

Convenience method for checking if index status is INDEX_STATUS_REINDEX_REQUIRED.

set_index_status_recreate_required

Convenience method for setting index status to INDEX_STATUS_RECREATE_REQUIRED.

is_index_status_recreate_required

Convenience method for checking if index status is INDEX_STATUS_RECREATE_REQUIRED.

index_status($status)

Will either set the current index status to $status and return $status, or return the current index status if called with no arguments.

$status

Optional argument. If passed will set current index status to $status if $status is a valid status. See "CONSTANTS".

update_mappings

Generate Elasticsearch mappings from mappings stored in database and perform a request to update Elasticsearch index mappings. Will throw an error and set index status to INDEX_STATUS_RECREATE_REQUIRED if update failes.

update_index_background($record_numbers, $server)

This has exactly the same API as update_index however it'll return immediately. It'll start a background process that does the adding.

If it fails to add to Elasticsearch then it'll add to a queue that will cause it to be updated by a regular index cron job in the future.

index_records

This function takes an array of record numbers and fetches the records to send to update_index for actual indexing.

If $records parameter is provided the records will be used as-is, this is only utilized for authorities at the moment.

The other variables are used for parity with Zebra indexing calls. Currently the calls are passed through to Zebra as well.

Will obey the chunk_size defined in koha-conf for amount of records to send during a single reindex, or default to 5000.

delete_index($biblionums)

$biblionums is an arrayref of biblionumbers to delete from the index.

delete_index_background($biblionums)

Identical to "delete_index($biblionums)"

drop_index

Drops the index from the Elasticsearch server.

create_index

Creates the index (including mappings) on the Elasticsearch server.

index_exists

Checks if index has been created on the Elasticsearch server. Returns 1 or the empty string to indicate whether index exists or not.

AUTHOR

Chris Cormack <chrisc@catalyst.net.nz>
Robin Sheat <robin@catalyst.net.nz>

<<