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_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.
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::Record
s.
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.
$status
Optional 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.
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.
$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>