本文整理汇总了Python中whoosh.qparser.QueryParser.matcher方法的典型用法代码示例。如果您正苦于以下问题:Python QueryParser.matcher方法的具体用法?Python QueryParser.matcher怎么用?Python QueryParser.matcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类whoosh.qparser.QueryParser
的用法示例。
在下文中一共展示了QueryParser.matcher方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Schema
# 需要导入模块: from whoosh.qparser import QueryParser [as 别名]
# 或者: from whoosh.qparser.QueryParser import matcher [as 别名]
from whoosh.index import create_in
from whoosh.fields import *
from whoosh.qparser import QueryParser
from whoosh.highlight import PinpointFragmenter
if __name__ == '__main__':
schema = Schema(title=TEXT(stored=True), path=ID(stored=True), content=TEXT(stored=True, chars=True))
ix = create_in("../indexdir", schema)
writer = ix.writer()
writer.add_document(title=u"Guideline", path=u"/a", content=u"""content""")
writer.commit()
with ix.searcher() as searcher:
query = QueryParser("content", ix.schema).parse(u"neutropenia")
matcher = query.matcher(searcher)
while matcher.is_active():
print "Docnum:", matcher.id()
print "Score:", matcher.score()
print "List of occurances:"
for span in matcher.spans():
print " Start word #", span.start, "End word #", span.end
# This prints "None" unless you used chars=True in the field
print " Start char #", span.startchar, "End char #", span.endchar
# Move to the next match
matcher.next()