Example #1
0
def migrate_collected_metadata(index, delete):
    cgms = CollectionSubmission.objects.filter(
        collection__provider__isnull=False,
        collection__is_public=True,
        collection__deleted__isnull=True,
        collection__is_bookmark_collection=False)

    docs = helpers.scan(
        es_client(),
        query={'query': {
            'match': {
                '_type': 'collectionSubmission'
            }
        }},
        index=index)

    actions = ({
        '_op_type': 'delete',
        '_index': index,
        '_id': doc['_source']['id'],
        '_type': 'collectionSubmission',
        'doc': doc['_source'],
        'doc_as_upsert': True,
    } for doc in list(docs))

    bulk_update_cgm(None, actions=actions, op='delete', index=index)

    bulk_update_collected_metadata(cgms, index=index)
    logger.info('{} collection submissions migrated'.format(cgms.count()))
Example #2
0
def migrate_collected_metadata(index, delete):
    cgms = CollectedGuidMetadata.objects.filter(
        collection__provider__isnull=False,
        collection__is_public=True,
        collection__deleted__isnull=True,
        collection__is_bookmark_collection=False)

    docs = helpers.scan(es_client(), query={
        'query': {'match': {'_type': 'collectionSubmission'}}
    }, index=index)

    actions = ({
        '_op_type': 'delete',
        '_index': index,
        '_id': doc['_source']['id'],
        '_type': 'collectionSubmission',
        'doc': doc['_source'],
        'doc_as_upsert': True,
    } for doc in list(docs))

    bulk_update_cgm(None, actions=actions, op='delete', index=index)

    bulk_update_collected_metadata(cgms, index=index)
    logger.info('{} collection submissions migrated'.format(cgms.count()))
Example #3
0
def bulk_update_collected_metadata(cgms, op='update', index=None):
    index = index or settings.ELASTIC_INDEX
    search_engine.bulk_update_cgm(cgms, op=op, index=index)