API Docs

Index syncing module.

class invenio_index_migrator.api.Job(name, migration, config)[source]

Index migration job.

Initialize a migration job.

Parameters:
  • name – job’s name.
  • migration – an invenio_index_migrator.api.migration.Migration object.
  • config – job’s configuration.
cancel()[source]

Cancel the job.

create_index(index)[source]

Create indexes needed for the job.

document_name

Get the document name for the job.

rollover_actions()[source]

Rollover actions.

run()[source]

Run the job.

src_es_client

Get the source ES client.

status()[source]

Return the status of the job.

class invenio_index_migrator.api.Migration(name, **config)[source]

Index migration base class.

cancel()[source]

Cancel migration and all its jobs.

classmethod create_from_config(recipe_name, **recipe_config)[source]

Create Migration instance from config.

classmethod create_from_state(recipe_name, **recipe_config)[source]

Create Migration instance from ES state.

create_index()[source]

Create Elasticsearch index for the migration.

init(dry_run=False)[source]

Initialize the index with recipe and jobs documents.

load_jobs_from_config()[source]

Load jobs from config.

notify()[source]

Notify when rollover is possible.

Override this to notify the user whenever the threshold is reached and a rollover is possible.

rollover(force=False)[source]

Perform a rollover action.

run()[source]

Run the index sync job.

status()[source]

Get status for index sync job.

strategy[source]

Return migration strategy.

class invenio_index_migrator.api.MultiIndicesReindexJob(name, migration, config)[source]

Reindex job that uses Elasticsearch’s reindex API.

Initialize a migration job.

Parameters:
  • name – job’s name.
  • migration – an invenio_index_migrator.api.migration.Migration object.
  • config – job’s configuration.
create_index(index)[source]

Create templates.

initial_state(dry_run=False)[source]

Build job’s initial state.

rollover_actions()[source]

Rollover actions.

run()[source]

Fetch source index using ES Reindex API.

class invenio_index_migrator.api.ReindexJob(name, migration, config)[source]

Reindex job that uses Elasticsearch’s reindex API.

Initialize a migration job.

Parameters:
  • name – job’s name.
  • migration – an invenio_index_migrator.api.migration.Migration object.
  • config – job’s configuration.
cancel()[source]

Cancel reindexing job.

initial_state(dry_run=False)[source]

Build job’s initial state.

run()[source]

Fetch source index using ES Reindex API.

class invenio_index_migrator.api.ReindexAndSyncJob(name, migration, config)[source]

Job that both reindexes with ES reindex API and syncs with the DB.

The first run will use the reindex API and the subsequent runs will fetch from the database and sync the data.

Initialize a migration job.

Parameters:
  • name – job’s name.
  • migration – an invenio_index_migrator.api.migration.Migration object.
  • config – job’s configuration.
cancel()[source]

Cancel reinding and syncing job.

iter_indexer_ops(start_date=None, end_date=None)[source]

Iterate over documents that need to be reindexed.

run()[source]

Run reindexing and syncing job.

run_delta_job()[source]

Calculate delta from DB changes since the last update.

Utilities

Utility functions for index migration.

class invenio_index_migrator.utils.ESClient(es_config)[source]

ES clinet for sync jobs.

.

client[source]

Return ES client.

reindex_auth[source]

Return username and password for reindex HTTP authentication.

reindex_remote[source]

Return ES client reindex API host.

class invenio_index_migrator.utils.State(index, document_id, client=None)[source]

Migration ES state.

The state is stored in ElasticSearch and can be accessed similarly to a python dictionary.

Synchronization job state in ElasticSearch.

commit(state)[source]

Save the state to ElasticSearch.

create(initial_state, force=False)[source]

Create state document.

read()[source]

Fetch the current state from Elasticsearch.

invenio_index_migrator.utils.extract_doctype_from_mapping(mapping_fp)[source]

Extract the doc_type from mapping filepath.

invenio_index_migrator.utils.get_queue_size(queue)[source]

Get the queue size.

invenio_index_migrator.utils.obj_or_import_string(value, default=None)[source]

Import string or return object.

Params value:Import path or class object to instantiate.
Params default:Default object to return if the import fails.
Returns:The imported object.