lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Naber <>
Subject Re: Strange sort error
Date Wed, 13 Apr 2005 22:11:16 GMT
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

  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.



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

View raw message