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",
javaC.compare("liu yu", "l yy") < 0);
java.text.RuleBasedCollator adjustedC = new
java.text.RuleBasedCollator(
((java.text.RuleBasedCollator)javaC).getRules().
replace("<'\u005f'", "<' '<'\u005f'"));
assertTrue("Spaces should be significant inside strings after
adjust",
adjustedC.compare("liu yu", "l yy") > 0);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]