本文整理汇总了Python中whoosh.writing.AsyncWriter.delete_document方法的典型用法代码示例。如果您正苦于以下问题:Python AsyncWriter.delete_document方法的具体用法?Python AsyncWriter.delete_document怎么用?Python AsyncWriter.delete_document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类whoosh.writing.AsyncWriter
的用法示例。
在下文中一共展示了AsyncWriter.delete_document方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: from whoosh.writing import AsyncWriter [as 别名]
# 或者: from whoosh.writing.AsyncWriter import delete_document [as 别名]
assert len(latest_backends_revids) == 1 # this item must have only one latest revision
latest_backend_revid = latest_backends_revids[0]
# we must fetch from backend because schema for LATEST_REVS is different than for ALL_REVS
# (and we can't be sure we have all fields stored, too)
meta, _ = self.backend.retrieve(*latest_backend_revid)
# we only use meta (not data), because we do not want to transform data->content again (this
# is potentially expensive) as we already have the transformed content stored in ALL_REVS index:
with self.ix[ALL_REVS].searcher() as searcher:
doc = searcher.document(revid=latest_backend_revid[1])
content = doc[CONTENT]
doc = backend_to_index(meta, content, self.schemas[LATEST_REVS], self.wikiname,
backend_name=latest_backend_revid[0])
writer.update_document(**doc)
else:
# this is no revision left in this item that could be the new "latest rev", just kill the rev
writer.delete_document(docnum_remove)
def _modify_index(self, index, schema, wikiname, revids, mode='add', procs=1, limitmb=256):
"""
modify index contents - add, update, delete the indexed documents for all given revids
Note: mode == 'add' is faster but you need to make sure to not create duplicate
documents in the index.
"""
with index.writer(procs=procs, limitmb=limitmb) as writer:
for backend_name, revid in revids:
if mode in ['add', 'update', ]:
meta, data = self.backend.retrieve(backend_name, revid)
content = convert_to_indexable(meta, data, is_new=False)
doc = backend_to_index(meta, content, schema, wikiname, backend_name)
if mode == 'update':