lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Koop <...@timkoop.com>
Subject Sorting by multiple dependent fields
Date Wed, 23 Mar 2011 16:27:10 GMT
I'm trying to sort on two dependent fields.  I realize that if they were 
independent I could use new Sort(SortField...) with lots of SortFields, 
but I need to compute something based on two fields.

Let me explain:

I'm searching for things near your location (as specified by longitude 
and latitude).  I've got the search working correctly (with the help of 
NumericField), but now I need to sort the results by distance from you.  
The closer things appear at the top of the list.  I can't store the 
distance, because I'll never know where you are searching from, so I 
need to calculate it at the time I sort.

How can I do this?  I'm thinking I might need to subclass the Sort 
object.  Or can I subclass the SortField object and give it two field names?

Thanks in advance!

-- 
Tim Koop
<mailto:tim@timkoop.com>
<http://www.timkoop.com>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message