lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@lucene.com>
Subject Re: unexpected behavior with reader.terms(term) not folowing contract
Date Wed, 10 Sep 2003 17:25:23 GMT
Bruce Ritchie wrote:
> TermEnum enum = reader.terms(new Term(field, start));
> 
> It is indeed possible that the '10' value could be text from another field.
> 
> I must say that as a user of the API I'm (obviously) surprised if the 
> above API call returned any results outside of the field specified. If 
> that is indeed the case if is almost certainly the cause of the issue. 
> I'll add some more logging to confirm.

Sorry for the surprise!  A TermEnum enumerates all of the terms in an 
index, ordered first by field, then, within that, by text.  It can be 
repositioned randomly, but that repositioning does not constrain the 
enumeration to the field of the term last repositioned to.  So, if you 
wish to only enumerate the terms of a particular field, you need to 
check that in your loop.  Note that field names are interned strings, so 
you can use '==' instead of 'String.equals(String)', making this test 
quite fast.

Doug


Mime
View raw message