lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Curtin" <m...@curtin.com>
Subject Re: IndexReader question
Date Thu, 17 Nov 2005 22:15:49 GMT
I think you want to access the TermEnum from IndexReader's terms() method.  
Depending upon how many fields you have an which ones you're interested in 
for term frequencies, something like this should get you started:

String dir = "topleveldir";
IndexReader ir = new IndexReader(FSDirectory.getDirectory(new File(dir), 
false));
TermEnum terms = ir.terms();
while (terms.next()) {
     System.out.printf("%s: %d\n", terms.term().text(), terms.docFreq());
}
terms.close();
ir.close();

I've glossed over a bunch of error handling and what to do if you want 
frequency information from only one field of an index that has several, but it 
should be enough to get you started.

BTW, you might want to generate the javadocs for the Lucene classes if you're 
going to be delving in like this.

Good luck!

--MDC

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message