Lisheng,

Have a look at the javadoc for the Sort object:
Valid Types of Values

 There are three possible kinds of term values which may be put into
 sorting fields: Integers, Floats, or Strings.  Unless
 SortField objects are specified, the type of value
 in the field is determined by parsing the first term in the field.

 

Thus, if you know what type of a value yoru field has, use SortField and 
explicitly set it.  Also, instantiate Sort and SortField only once instead of 
in each call to search(....).

Otis
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Lucene Consulting - http://lucene-consulting.com/


----- Original Message ----
From: "Zhang, Lisheng" <[EMAIL PROTECTED]>
To: java-user@lucene.apache.org
Sent: Saturday, April 28, 2007 9:04:23 PM
Subject: Sort in Lucene 1.4.3

Hi,

I encountered one problem in lucene 1.4.3: I called 

Searcher.search(<query>, new Sort("myfiled");

In "myfiled", most values looks like number "123456" or sth
similiar, but one field contains a value "Just a TRY", then
I got error:

java.lang.ClassCastException at
org.pache.lucene.search.FieldDocSortedHitQueue.lssThan
(FieldDocSortedHitQueue.java:129)

It seems that lucene judged this field as number so it 
cannot cast one particular value as String?

To me if client did not specify sorting field type, we should
treat it just as String?

Thanks very much for helps and best regards, Lisheng



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to