lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Toke Eskildsen>
Subject RE: Lucene search result produced wrong result (due to java Collation)?
Date Tue, 01 Mar 2011 07:33:38 GMT
On Mon, 2011-02-28 at 22:44 +0100, Zhang, Lisheng wrote:
> 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

The standard Java Collator ignores whitespace. It can be hacked, but you
will have to write your own implementation to get Lucene to sort in the
desired way. FieldComparatorSource is a good place to start.

A code snippet demonstrating the Collator-hack:

    public void testJavaStandardCollator() throws Exception {
        java.text.Collator javaC =
            java.text.Collator.getInstance(new Locale("EN"));
        assertTrue("Spaces should be ignored per default",
         "liu yu", "l yy") < 0);

        java.text.RuleBasedCollator adjustedC = new
                    replace("<'\u005f'", "<' '<'\u005f'"));
        assertTrue("Spaces should be significant inside strings after
         "liu yu", "l yy") > 0);

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

View raw message