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 RE: Lucene search result produced wrong result (due to java Collation)?
Date Mon, 28 Feb 2011 21:44:22 GMT
Hi,

Very sorry I made a typo, what I meant to say is that lucene sort produced wrong
result in English names (String ASC):

liu yu
l yy

(previously I put other way round), and the problem is in java Collator which lucene
is using (I can produce bug by sample code below).

Thanks very much for helps, Lisheng

-----Original Message-----
From: Zhang, Lisheng [mailto:Lisheng.Zhang@BroadVision.com]
Sent: Saturday, February 26, 2011 5:00 PM
To: java-user@lucene.apache.org
Subject: Lucene search result produced wrong result (due to java
Collation)?



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


---------------------------------------------------------------------
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