def index_bulk(collection, entities, chunk_size=200): """Index a set of entities.""" for attempt in count(): try: entities = _index_updates(collection, entities) bulk_op(entities, chunk_size=chunk_size) return except (BulkIndexError, TransportError) as exc: log.warning('Indexing error: %s', exc) backoff_cluster(failures=attempt)
def index_records(document): if not document.supports_records: return clear_records(document.id) for attempt in count(): try: bulk_op(generate_records(document)) refresh_index(records_index()) return except Exception as exc: log.warning('Failed to index records: %s', exc) backoff_cluster(failures=attempt)