lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Curtin" <>
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), 
TermEnum terms = ir.terms();
while ( {
     System.out.printf("%s: %d\n", terms.term().text(), terms.docFreq());

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!


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message