本文整理汇总了Python中invenio_indexer.api.RecordIndexer.delete_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python RecordIndexer.delete_by_id方法的具体用法?Python RecordIndexer.delete_by_id怎么用?Python RecordIndexer.delete_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invenio_indexer.api.RecordIndexer
的用法示例。
在下文中一共展示了RecordIndexer.delete_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: indexed_loans
# 需要导入模块: from invenio_indexer.api import RecordIndexer [as 别名]
# 或者: from invenio_indexer.api.RecordIndexer import delete_by_id [as 别名]
def indexed_loans(es, test_loans):
"""Get a function to wait for records to be flushed to index."""
indexer = RecordIndexer()
for pid, loan in test_loans:
indexer.index(loan)
current_search.flush_and_refresh(index="loans")
yield test_loans
for pid, loan in test_loans:
indexer.delete_by_id(loan.id)
current_search.flush_and_refresh(index="loans")
示例2: remove_records
# 需要导入模块: from invenio_indexer.api import RecordIndexer [as 别名]
# 或者: from invenio_indexer.api.RecordIndexer import delete_by_id [as 别名]
def remove_records(app, record_ids):
"""Remove all records."""
with app.app_context():
indexer = RecordIndexer()
for r_id in record_ids:
record = RecordMetadata.query.get(r_id)
indexer.delete_by_id(r_id)
pids = PersistentIdentifier.query.filter_by(
object_uuid=r_id).all()
for pid in pids:
db.session.delete(pid)
db.session.delete(record)
db.session.commit()