Skip to content

Commit

Permalink
tests: initialize bulk index queue in doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
slint committed Dec 1, 2017
1 parent 707efa7 commit 87e72c5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions invenio_indexer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,20 @@
Bulk indexing
-------------
If you have many records to index, bulk indexing is far superior in speed to
single record indexing.
single record indexing. Bulk indexing requires the existence of a queue on your
broker, so since this is the very first time we send any records for bulk
indexing, we will have to create this queue:
>>> from celery.messaging import establish_connection
>>> queue = app.config['INDEXER_MQ_QUEUE']
>>> with establish_connection() as conn:
... queue(conn).declare()
We can now send a record for bulk indexing:
>>> indexer.bulk_index([str(r.id)])
Above will send the record id to a queue on your broker and wait for the bulk
Above will send the record id to the queue on your broker and wait for the bulk
indexer to execute. This is normally done in the background by a Celery task
which can be started from the command line like e.g.:
Expand Down

0 comments on commit 87e72c5

Please sign in to comment.