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


Python QueryParser.matcher方法代码示例

本文整理汇总了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()
开发者ID:rezwan4438,项目名称:ProvenanceCurious,代码行数:27,代码来源:test_ds.py


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