当前位置: 首页>>代码示例>>Python>>正文


Python RecordIndexer.delete方法代码示例

本文整理汇总了Python中invenio_indexer.api.RecordIndexer.delete方法的典型用法代码示例。如果您正苦于以下问题:Python RecordIndexer.delete方法的具体用法?Python RecordIndexer.delete怎么用?Python RecordIndexer.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在invenio_indexer.api.RecordIndexer的用法示例。


在下文中一共展示了RecordIndexer.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index_after_commit

# 需要导入模块: from invenio_indexer.api import RecordIndexer [as 别名]
# 或者: from invenio_indexer.api.RecordIndexer import delete [as 别名]
def index_after_commit(sender, changes):
    """Index a record in ES after it was committed to the DB.

    This cannot happen in an ``after_record_commit`` receiver from Invenio-Records
    because, despite the name, at that point we are not yet sure whether the record
    has been really committed to the DB.
    """
    indexer = RecordIndexer()
    for model_instance, change in changes:
        if isinstance(model_instance, RecordMetadata):
            if change in ('insert', 'update') and not model_instance.json.get("deleted"):
                if hasattr(model_instance, '_enhanced_record'):
                    record = model_instance._enhanced_record
                else:
                    record = model_instance.json
                indexer.index(InspireRecord(record, model_instance))
            else:
                try:
                    indexer.delete(InspireRecord(
                        model_instance.json, model_instance))
                except NotFoundError:
                    # Record not found in ES
                    LOGGER.debug('Record %s not found in ES',
                                 model_instance.json.get("id"))
                    pass

            pid_type = get_pid_type_from_schema(model_instance.json['$schema'])
            pid_value = model_instance.json['control_number']
            db_version = model_instance.version_id

            index_modified_citations_from_record.delay(pid_type, pid_value, db_version)
开发者ID:harunurhan,项目名称:inspire-next,代码行数:33,代码来源:receivers.py

示例2: receive_after_model_commit

# 需要导入模块: from invenio_indexer.api import RecordIndexer [as 别名]
# 或者: from invenio_indexer.api.RecordIndexer import delete [as 别名]
def receive_after_model_commit(sender, changes):
    """Perform actions after models committed to database."""
    indexer = RecordIndexer()
    for model_instance, change in changes:
        if isinstance(model_instance, RecordMetadata):
            if change in ('insert', 'update'):
                indexer.index(InspireRecord(model_instance.json, model_instance))
            else:
                indexer.delete(InspireRecord(model_instance.json, model_instance))
开发者ID:fschwenn,项目名称:inspire-next,代码行数:11,代码来源:receivers.py

示例3: _delete_record_from_everywhere

# 需要导入模块: from invenio_indexer.api import RecordIndexer [as 别名]
# 或者: from invenio_indexer.api.RecordIndexer import delete [as 别名]
def _delete_record_from_everywhere(pid_type, record_control_number):
    record = get_db_record(pid_type, record_control_number)

    ri = RecordIndexer()
    ri.delete(record)
    record.delete(force=True)

    pid = PersistentIdentifier.get(pid_type, record_control_number)
    PersistentIdentifier.delete(pid)

    object_uuid = pid.object_uuid
    PersistentIdentifier.query.filter(
        object_uuid == PersistentIdentifier.object_uuid).delete()

    db.session.commit()
开发者ID:bittirousku,项目名称:inspire-next,代码行数:17,代码来源:test_record.py

示例4: index_after_commit

# 需要导入模块: from invenio_indexer.api import RecordIndexer [as 别名]
# 或者: from invenio_indexer.api.RecordIndexer import delete [as 别名]
def index_after_commit(sender, changes):
    """Index a record in ES after it was committed to the DB.

    This cannot happen in an ``after_record_commit`` receiver from Invenio-Records
    because, despite the name, at that point we are not yet sure whether the record
    has been really committed to the DB.
    """
    indexer = RecordIndexer()

    for model_instance, change in changes:
        if isinstance(model_instance, RecordMetadata):
            if change in ('insert', 'update'):
                indexer.index(Record(model_instance.json, model_instance))
            else:
                indexer.delete(Record(model_instance.json, model_instance))
开发者ID:david-caro,项目名称:inspire-next,代码行数:17,代码来源:receivers.py


注:本文中的invenio_indexer.api.RecordIndexer.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。