You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by Bill Blinn <bb...@gmail.com> on 2006/11/10 16:10:27 UTC

Overflow exception when sorting by a date field

I'm trying to sort a query's results by a field that contains a date value,
but I'm getting OverflowExceptions. Here's an example stack trace

System.OverflowException : Value was either too large or too small for an
Int32.
    at System.Number.ParseInt32(String s, NumberStyles style,
NumberFormatInfo info)
    at System.Int32.Parse(String s)
    at Lucene.Net.Search.FieldCacheImpl.AnonymousClassIntParser.ParseInt(String
value_Renamed)
    at Lucene.Net.Search.FieldCacheImpl.GetInts(IndexReader reader, String
field, IntParser parser)
    at Lucene.Net.Search.FieldCacheImpl.GetInts(IndexReader reader, String
field)
    at Lucene.Net.Search.FieldCacheImpl.GetAuto (IndexReader reader, String
field)
    at Lucene.Net.Search.FieldSortedHitQueue.ComparatorAuto(IndexReader
reader, String fieldname)
    at Lucene.Net.Search.FieldSortedHitQueue.GetCachedComparator(IndexReader
reader, String fieldname, Int32 type, CultureInfo locale,
SortComparatorSource factory)
    at Lucene.Net.Search.FieldSortedHitQueue..ctor(IndexReader reader,
SortField[] fields, Int32 size)
    at Lucene.Net.Search.IndexSearcher.Search(Weight weight, Filter filter,
Int32 nDocs, Sort sort)
    at Lucene.Net.Search.Hits.GetMoreDocs (Int32 min)
    at Lucene.Net.Search.Hits..ctor(Searcher s, Query q, Filter f, Sort o)
    at Lucene.Net.Search.Searcher.Search(Query query, Sort sort)

The date field is stored as a string and is constructed using:
DateTools.DateToString(time, DateTools.Resolution.SECOND);, where time is a
System.DateTime. Am I doing something wrong, or is a workaround for this
aside from sorting myself?

thanks,
bill