Skip to content

Instantly share code, notes, and snippets.

@dopuskh3
Created October 5, 2009 10:46
Show Gist options
  • Save dopuskh3/202047 to your computer and use it in GitHub Desktop.
Save dopuskh3/202047 to your computer and use it in GitHub Desktop.
def search( searchRequest, idxPath):
initVM(CLASSPATH)
fsDir = FSDirectory.getDirectory(idxPath, False)
searcher = IndexSearcher(fsDir)
language = StandardAnalyzer()
queryp = QueryParser('all', language)
query = queryp.parse(searchRequest) # "title", language)
hits = searcher.search(query)
print "# Found %d hits for %s"%(len(hits), searchRequest)
for i in range(0, hits.length()):
doc = hits.doc(i)
#print u"# %s - %s - %s"%(doc.getField('artist'), doc.getField('album'), doc.getField('title'))
print u"%s"%unicode(doc.getField('path').stringValue())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment