lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Digy" <digyd...@gmail.com>
Subject RE: Sort by 2 fields or concatenated data
Date Fri, 23 Jul 2010 22:26:21 GMT
Is it possible to show the case with a small code fragment?

DIGY

-----Original Message-----
From: Martyn Braithwaite [mailto:mbraithwaite@openroad.ca] 
Sent: Friday, July 23, 2010 10:46 PM
To: lucene-net-dev@lucene.apache.org
Subject: Sort by 2 fields or concatenated data

I am having trouble with sorting results correctly.



I am using Lucene.Net 2.9.2



I have a field that contains LastName|FirstName data and is un-tokenized.
 This field can contain diacritic characters.



I have tried the following.



1.       Using the SortField(name, locale, reversed) class

2.       Create a custom FieldComparatorSource (this splits on the | and
tries to sort by the last name portion first and then the first name if the
last name is the same)

3.       Adding 2 SortField fields, one for last name and one for first
name.



In the end they all produce the same result which is:



YÀNG|YING
YATES|AISLIN
YATES|ALEXANDREA
YATES|BRUCE
YATES|DOREEN
YATES|GAYELORD
YATES|LAVONE
YATES|LIZZIE
YATES|PRUNELLA
YATES|RONALD
*YÀTES|RONA*

YATES|TANZI
YATES|TATUM
YATES|TRISTAN
YATES|WELDON
YÀTES|XAVIOR



But if I run the code from the custom FieldComparator using a List<String>
Sort with a simple IComparer I get



YÀNG|YING
YATES|AISLIN
YATES|ALEXANDREA
YATES|BRUCE
YATES|DOREEN
YATES|GAYELORD
YATES|LAVONE
YATES|LIZZIE
YATES|PRUNELLA
YATES|RONALD
YATES|TANZI
YATES|TATUM
YATES|TRISTAN
YATES|WELDON
*YÀTES|RONA*
YÀTES|XAVIOR



This is the correct alphabetical order



Is it possible to get Lucene to sort the results the same way as the
IComparer? How should I store the data in the index if I want to sort
LastName / FirstName?



Thanks for any help.


Mime
View raw message