lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vanshi <nilu.tha...@gmail.com>
Subject Custom sorting!
Date Thu, 04 Jun 2009 19:55:04 GMT

I am doing custom sorting within lucene using overloaded
searcher.search(query, sort). First precedence is to sort based on 'last
name' and then on 'network status', where 'INN' is better than 'OUT'.

Fields are stored in the indexes like this:

FIRST_NAME(Field.Store.NO, Field.Index.NO_NORMS)
LAST_NAME_EXACT(Field.Store.NO, Field.Index.NO_NORMS)

And analyzer used is 'keyword analyzer' on these fields. And the fields are
sorted with following lines.

ArrayList<SortField> sorts = new ArrayList<SortField>();
sorts.add(new SortField("LAST_NAME_EXACT"));
sorts.add(new SortField(ProviderFieldInfo.NETWORK.toString(),
networkComparatorSource));
super.setSort(sorts.toArray(new SortField[sorts.size()]));

Now, with the above line my expectation is to see 'last name' sorted
alphabatically and then if two 'last names' are same then 'network
status(INN/OUT)' must get precedence and if both 'network status' and 'last
name' are same then socre will decide the order. Is this expectation wrong??

The result I'm getting is in this order: The query used is a prefix query,
where 'last name' entered is 'john' and first name is 'p'. 

JOHNSON, PETER A 	INN
JOHNSON, PETER B		INN
JOHNSON, PEGGY A	OUT
JOHNSON, PHILLIP W	INN
JOHNSON-STUHR, PAMELA J	OUT
JOHN, P G		INN
JOHNSON, PAUL G		INN
JOHNSON, PETER R		INN

Can somebody take alook and see what should be done to get expected results? 

Thanks,
Vanshi
 
-- 
View this message in context: http://www.nabble.com/Custom-sorting%21-tp23876641p23876641.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Mime
View raw message