Hi Franklin, Good catch. It seems to be a bug. Can you open a new JIRA issue for that and attach your patch?
DIGY -----Original Message----- From: Franklin Simmons [mailto:fsimm...@sccmediaserver.com] Sent: Friday, May 29, 2009 10:23 PM To: lucene-net-dev@incubator.apache.org Subject: bug in SegmentTermVector.IndexOf ? Greetings, I hope I have this all wrong; I haven't seen this issue raised. At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare: public virtual int IndexOf(System.String termText) { if (terms == null) return - 1; int res = System.Array.BinarySearch(terms, termText); return res >= 0 ? res : - 1; } As implemented this method always (for me, anyway) returns a negative number. The modification below works, but I need to know if this is actually a bug and if so, what is the correct fix. public class SegmentTermVector : TermFreqVector { . . . private class TermVectorComparer : System.Collections.IComparer { public int Compare(object a, object b) { return String.CompareOrdinal((string)a, (string)b); } } public virtual int IndexOf(System.String termText) { if (terms == null) return - 1; int res = System.Array.BinarySearch(terms, termText, new TermVectorComparer()); return res >= 0 ? res : - 1; } . . . } Franklin Simmons