lucene-java-user mailing list archives

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


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

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  =" +, s2));
    System.out.println("STRI_RES  =" + s1.compareTo(s2));

The result is:

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:
For additional commands, e-mail:

View raw message