lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martyn Braithwaite <mbraithwa...@openroad.ca>
Subject Sort by 2 fields or concatenated data
Date Fri, 23 Jul 2010 19:45:53 GMT
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message