You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Praveen Peddi <pp...@contextmedia.com> on 2004/12/29 18:36:22 UTC

sorting on a non english based locale field

Hi fellow luceners,
I was looking at the lucene sorting code and it looks like lucene does consider locale into account while sorting. So I assume lucene already handles for strings.

But in my case, I wrote my own SortComparator (StringIgnoreCaseSortComparator) to achieve sorting similar to explorer sorting. Because lucene uses java's string.compareTo method and that considers  "case" of each character, I can't use lucene's default string sorting.

The question is, how do I integrate Locale into my StringIgnoreCaseSortComparator while comparing strings. Lucene's code gets the locale from SortField but I don't have access to SortField in this comparator.

Any ideas???? Should StringIgnoreCaseSortComparator be just knowing the locale at the time of instantiating?

Praveen

************************************************************** 
Praveen Peddi
Sr Software Engg, Context Media, Inc. 
email:ppeddi@contextmedia.com 
Tel:  401.854.3475 
Fax:  401.861.3596 
web: http://www.contextmedia.com 
************************************************************** 
Context Media- "The Leader in Enterprise Content Integration" 

Re: sorting on a non english based locale field

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Dec 29, 2004, at 12:36 PM, Praveen Peddi wrote:
> Hi fellow luceners,
> I was looking at the lucene sorting code and it looks like lucene does 
> consider locale into account while sorting. So I assume lucene already 
> handles for strings.
>
> But in my case, I wrote my own SortComparator 
> (StringIgnoreCaseSortComparator) to achieve sorting similar to 
> explorer sorting. Because lucene uses java's string.compareTo method 
> and that considers  "case" of each character, I can't use lucene's 
> default string sorting.
>
> The question is, how do I integrate Locale into my 
> StringIgnoreCaseSortComparator while comparing strings. Lucene's code 
> gets the locale from SortField but I don't have access to SortField in 
> this comparator.
>
> Any ideas???? Should StringIgnoreCaseSortComparator be just knowing 
> the locale at the time of instantiating?

Yes, when using a custom sorting implementation, you need to hand it 
whatever information it needs to do the sorting.  The Locale parameters 
to SortField are used only in the built-in mechanisms and not part of 
the API for using a custom implementation.

	Erik


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