On Tuesday 12 April 2005 20:04, Bill Tschumy wrote: > Here is a small program that will manifest the error. ÂHopefully  > someone can explain the problem. ÂIt happens with Lucene 1.4.2 and  > 1.4.3.
This is the code that throws the exception (from FieldCacheImpl.java): TermEnum termEnum = reader.terms (new Term (field, "")); (...) if (termEnum.term() == null) { throw new RuntimeException ("no terms in field " + field); } The problem is that a TermEnum always returns all terms after a given one, not only terms in the same field. So the check is incomplete. If one changes the if like this, one will always get an exception if there are no terms in the field, as the exception claims: if (termEnum.term() == null || !termEnum.term().field().equals(field)) { The other issue is that you probably expect to not get an exception at all, as there are no matches. Lucene doesn't first search and then sort, these tasks are parallel I think. So this is not that easy to fix (and I doubt if one should try). Could you open a bug report for the problem with the exception that seems to occur only sometimes? The change suggested above needs to be tested before it can be committed and a bug report is useful for that. Regards Daniel -- http://www.danielnaber.de --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]