本文整理汇总了Python中search.Search.make_term_query方法的典型用法代码示例。如果您正苦于以下问题:Python Search.make_term_query方法的具体用法?Python Search.make_term_query怎么用?Python Search.make_term_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search.Search
的用法示例。
在下文中一共展示了Search.make_term_query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_old
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import make_term_query [as 别名]
def delete_old(self, index):
existing_ids = set([book.id for book in Book.objects.all()])
reader = IndexReader.open(index.index, False)
searcher = IndexSearcher(reader)
try:
num = searcher.docFreq(Term('is_book', 'true'))
docs = searcher.search(Search.make_term_query(['true'], 'is_book'), num)
for result in docs.scoreDocs:
stored = searcher.doc(result.doc)
book_id = int(stored.get('book_id'))
if not book_id in existing_ids:
print "book id %d doesn't exist." % book_id
index.remove_book(book_id)
finally:
searcher.close()
reader.close()