lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: RuntimeException: cannot determine sort type!
Date Wed, 16 Jun 2004 12:20:14 GMT
On Jun 16, 2004, at 7:25 AM, wrote:
> Well, I just didn't  want to overload people with too much code.

There is an art to providing just enough detail :)

> doc is created like this ("modified" get formated with SimpleDateFormat
> tformat = new SimpleDateFormat ("yyyyMMddhhmmss") by cashToIndex metod,
> where the IndexWriter created) :
> doc.add(Field.Keyword("modified",DateField.timeToString(modified)));

This looks fine.

>                   formated_query=query.toString();
>                   if (sort_byscore)hits =;
>                   else hits =,new 
> Sort("modified",true));
> // here the "cannot determine.." exception generated!!!

How about using:,
            new Sort(new SortField("modified", SortField.STRING, true)));

Does that fix it?

If "modified" is only there for sorting and not for querying, perhaps 
index it as a Integer.toString or Float.toString instead - this will 
give you better resource usage and performance most likely - and change 
the type to SortField.INT or SortField.FLOAT appropriately.  The 
sorting infrastructure can detect a type, but it may have issues doing 
so if the strings look like a number in the first document but later 
appear like a String.  DateField.timeToString makes them String, so 
forcing it to sort on String type should work.


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

View raw message