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
|