lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vanshi <>
Subject Sorting fields while searching!
Date Mon, 01 Jun 2009 18:07:42 GMT

I have two fields initialized following way for Index writing:


I have a prefix query to look for any name starting with the name entered by
the user. Lets say user enters 'kar' as FName and 'johns' as last name and
then the prefix query becomes 'kar*' 'johns*'. I need to display result in
alphabatical order....that means 'kara johns' must come before 'karen
johns'. First I thought, prefix query itself will rank document with the
alphabatical order but that does not seem the case. So, now I'm trying to
sort while searching, with this code.....but I don't see any difference
between wht the results were before and what they are now. 

sorts.add(new SortField(PhysicianFieldInfo.FIRST_NAME_EXACT.toString(),
SortField.STRING ));
sorts.add(new SortField(PhysicianFieldInfo.LAST_NAME_EXACT.toString(),
SortField.STRING ));

After these 2 sorting, I'm also doing sorting on some other fields but i
guess the name sorting should take precedence over later sortings. Can
anybody suggest what I'm doing wrong here?

View this message in context:
Sent from the Lucene - Java Users mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message