lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Lef <ale...@sciquest.com>
Subject Unexpected TermEnum behavior
Date Wed, 08 Dec 2004 23:39:40 GMT
My application needs to enumerate all terms for a specific field. To do that
I get the TermEnum using the following code:

	TermEnum terms = reader.terms(new Term(fieldName, ""));

I noticed that initially TermEnum is positioned at the first term. In other
words, I don't have to call terms.next() before calling terms.term(). This
is different from the behavior of Iterator,  Enumeration and ResultSet whose
initial position is before the first result. I wonder whether it is this way
by design.

If it is by design, what is the defined TermEnum behavior if there are no
terms for the field name in question? Will the call to terms.term() return
null? Or get positioned at the first term with the field name that comes
after the provided field name? What if there are no field names after it?

In any case, some javadoc describing the behavior would be extremely useful.
Being used to Iterators and ResultSets, I automatically wrote the code the
same way, calling next() first. Fortunately, I had a field with only 2
terms, that's why I noticed that I am missing the first element.

Thanks,

Alexey

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message