I'm building up the Sort object for the search with 2 SortFields - first is for the custom rounded scoring, second is for date. This Sort object is used to construct a FieldSortedHitQueue which is used with a custom HitCollector. And yes, this comparator ignores the field name.
hmmm, actually i see now that SortField(String,SortComparatorSource) says
it cannot > be null ... not sure if that's actually enforced or not The constructor doesn't complain, but FieldSortedHitQueue expects a field name when it tries to locate the comparator from the cache: at org.apache.lucene.search.FieldCacheImpl$Entry.<init>( FieldCacheImpl.java:60) at org.apache.lucene.search.FieldSortedHitQueue.lookup( FieldSortedHitQueue.java:157) at org.apache.lucene.search.FieldSortedHitQueue.getCachedComparator( FieldSortedHitQueue.java:185) at org.apache.lucene.search.FieldSortedHitQueue.<init>( FieldSortedHitQueue.java:58) Peter On 2/27/07, Chris Hostetter <[EMAIL PROTECTED]> wrote:
: Suppose one wanted to use this custom rounding score comparator on all : fields and all queries. How would you get it plugged in most efficiently, : given that SortField requires a non-null field name? i'm not sure i understand the first part of question .. this custom SortComparatorSource would deal only with the score, it wouldn't matter what other fields you'd want to make SortFields on to do secondary sorting. .. You as the client have to specify the Sort obejct when executing the search, and you can build that Sort object up anyway you want. Yes the SortField class has a constructor arg for field, but as you can see from the javadocs, it can be null in many circumstances (consider SortFiled#FIELD_SCORE and SortField#FIELD_DOC for instance) ... hmmm, actually i see now that SortField(String,SortComparatorSource) says it cannot be null ... not sure if that's actually enforced or not, but it's no bother -- all that matters is that you don't make any attempt to use the field name in your SortComparatorSource. -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]