lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zhang, Lisheng" <Lisheng.Zh...@BroadVision.com>
Subject Lucene search result produced wrong result (due to java Collation)?
Date Sun, 27 Feb 2011 00:59:48 GMT

Hi,

Today I have noticed that sometimes lucene sort produced strange result in plain
English names, like (String ASC)

l yy
liu yu

I traced to lucene source code, it seems to be a java English Collator problem (I 
set Locale.English to SortField), below I reproduced issue by a trivial code (pure
java):

/////
import java.util.Locale;
import java.text.Collator;

public class T1 {
  static public void main(String[] argv) {

    String s1 = "l yy";
    String s2 = "liu yu";

    //s1 = "l";
    //s2 = "liu";

    Collator col1 = Collator.getInstance(Locale.US);
    System.out.println("COLL_RES  =" + col1.compare(s1, s2));
    System.out.println("STRI_RES  =" + s1.compareTo(s2));
  }
}
/////

The result is:

COLL_RES  =1
STRI_RES  =-73

I tested different java versions and get same result, maybe I missed sth trivial, but
above test is really simple?

Thanks very much for helps, Lisheng


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message