<<

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

FUNCTIONS

$indexer->update_index($biblionums, $records);

$biblionums is an arrayref containing the biblionumbers for the records.

$records is an arrayref containing the MARC::Records themselves.

The values in the arrays must match up, and the 999$c value in the MARC record will be rewritten using the values in $biblionums to ensure they are correct. If $biblionums is undef, this won't happen, but you should be sure that 999$c is correct on your own then.

Note that this will modify the original record if $biblionums is supplied. If that's a problem, clone them first.

$indexer->update_index_background($biblionums, $records)

This has exactly the same API as update_index_background 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.

# TODO implement in the future - I don't know the best way of doing this yet. # If fork: make sure process group is changed so apache doesn't wait for us.

$indexer->delete_index($biblionums)

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

$indexer->delete_index_background($biblionums)

Identical to delete_index, this will return immediately and start a background process to do the actual deleting.

$indexer->drop_index();

Drops the index from the elasticsearch server. Calling update_index after this will recreate it again.

AUTHOR

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

<<