本文整理汇总了Python中lucene.Document.get方法的典型用法代码示例。如果您正苦于以下问题:Python Document.get方法的具体用法?Python Document.get怎么用?Python Document.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lucene.Document
的用法示例。
在下文中一共展示了Document.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stdin
# 需要导入模块: from lucene import Document [as 别名]
# 或者: from lucene.Document import get [as 别名]
metadata={"asdfa":"asdfa"}
json_metadata=json.dumps(metadata)
doc.add(Field("metadata", json_metadata, Field.Store.YES, Field.Index.NO))
writer.addDocument(doc)
print "Indexed lines from stdin (%d documents in index)" % (writer.numDocs())
print "About to optimize index of %d documents..." % writer.numDocs()
writer.optimize()
print "...done optimizing index of %d documents" % writer.numDocs()
print "Closing index of %d documents..." % writer.numDocs()
print "...done closing index of %d documents" % writer.numDocs()
writer.close()
# RETRIEVAL
dir = SimpleFSDirectory(File(fullIndexDir))
analyzer = StandardAnalyzer(lucene.Version.LUCENE_CURRENT)
searcher = IndexSearcher(dir)
query = QueryParser(lucene.Version.LUCENE_CURRENT, "text", analyzer).parse(u"¿Dónde está La Mancha?")
MAX = 1000
hits = searcher.search(query, MAX)
print "Found %d document(s) that matched query '%s':" % (hits.totalHits, query)
for hit in hits.scoreDocs:
print hit.score, hit.doc, hit.toString()
doc = searcher.doc(hit.doc)
print doc.get("text").encode("utf-8")
print doc.get("metadata").encode("utf-8")