lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: Unexpected TermEnum behavior
Date Thu, 09 Dec 2004 00:13:19 GMT
: 	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

Well, strictly speeking it's very different -- in particular, the "next"
method doesn't return the item, which is also very different from
Iterators and Enumeration.

I agree it's a little confusing, esecially since TermDocs and TermEnum are
different.

: 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?

I believe that in those cases, the TermEnum object itself will be null.

: In any case, some javadoc describing the behavior would be extremely useful.

I thought it was documented in the TermEnum interface, but looking at it
now I realize that not only does the TermEnum javadoc not explain it
very well, but the class FilteredTermEnum (which implements TermEnum)
acctually documents the oposite behavior...

  public Term term()

      Returns the current Term in the enumeration. Initially
      invalid, valid  after next() called for the first time.


-Hoss


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


Mime
View raw message