Koha::SearchEngine::Elasticsearch::Indexer - handles adding new records to the index
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new(
{ index => Koha::SearchEngine::BIBLIOS_INDEX } );
$indexer->drop_index();
$indexer->update_index(\@biblionumbers, \@records);
Koha::SearchEngine::Elasticsearch::Indexer::INDEX_STATUS_OKRepresents an index state where index is created and in a working state.
Koha::SearchEngine::Elasticsearch::Indexer::INDEX_STATUS_REINDEX_REQUIREDNot 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_REQUIREDRepresentings an index state where index needs to be recreated and is not in a working state.
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.
$biblionumsArrayref of biblio numbers for the $records, the order must be the same as and match up with $records.
$recordsArrayref of MARC::Records.
Convenience method for setting index status to INDEX_STATUS_OK.
Convenience method for checking if index status is INDEX_STATUS_OK.
Convenience method for setting index status to INDEX_REINDEX_REQUIRED.
Convenience method for checking if index status is INDEX_STATUS_REINDEX_REQUIRED.
Convenience method for setting index status to INDEX_STATUS_RECREATE_REQUIRED.
Convenience method for checking if index status is INDEX_STATUS_RECREATE_REQUIRED.
Will either set the current index status to $status and return $status, or return the current index status if called with no arguments.
$statusOptional argument. If passed will set current index status to $status if $status is a valid status. See "CONSTANTS".
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.
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.
$biblionums is an arrayref of biblionumbers to delete from the index.
Identical to "delete_index($biblionums)"
Drops the index from the Elasticsearch server.
Creates the index (including mappings) on the Elasticsearch server.
Checks if index has been created on the Elasticsearch server. Returns 1 or the empty string to indicate whether index exists or not.
<chrisc@catalyst.net.nz><robin@catalyst.net.nz>