It seems like you are trying to use the TermDocs iterator to load the term freq for that particular document (doc)?
It doesn't work that way -- instead, it simply iterates over all documents that this term occurred in. (Ie it will replace the doc in the int[] that you passed in, with the next doc in the term's postings).
If you only want to read one doc at a time, you should its next() method to advance, and then call doc() and freq(). When next() returns false, it means there are no more documents, so you should then break out of your loop.
Mike Carlos Rodríguez Fernández wrote:
Hello: I have a problem with TermDocs#read operation. the following code has an incorrect result: ..... int termFreq=0; ..... TermDocs termDocs = indexReader.termDocs(new Term(((Field)field).name(),termCons)); int[] freqs = new int[]{0}; termDocs.read(new int[]{doc}, freqs); termFreq+=freqs[0]; .... the freqs array always return with a "[1]" for all terms and for all documents. :S Can you help me please? Thanks a lot! Carlos
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]