Author: ssmiweve
Date: 2008-03-30 14:56:33 +0200 (Sun, 30 Mar 2008)
New Revision: 6312
Modified:
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/AbstractEnrichmentDirective.java
Log:
SEARCH-4386 - AbstractEnrichmentDirective, if several enrichments have the same
score only the first is used
Modified:
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/AbstractEnrichmentDirective.java
===================================================================
---
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/AbstractEnrichmentDirective.java
2008-03-29 18:50:41 UTC (rev 6311)
+++
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/AbstractEnrichmentDirective.java
2008-03-30 12:56:33 UTC (rev 6312)
@@ -34,6 +34,7 @@
import no.sesat.search.result.ResultList;
import no.sesat.search.site.Site;
import no.sesat.search.view.config.SearchTab;
+import org.apache.commons.lang.text.StrBuilder;
import org.apache.velocity.Template;
import static no.sesat.search.view.config.SearchTab.EnrichmentHint.*;
import org.apache.velocity.app.VelocityEngine;
@@ -115,9 +116,14 @@
final Set<ResultList> enrichments = enrichmentsExisting
? (Set<ResultList>)cxt.get("enrichments")
: new TreeSet<ResultList>(new Comparator<ResultList>(){
+
public int compare(ResultList o1, ResultList o2) {
// highest scores first, ie descending order.
- return (int)((Float)o2.getObjectField(SCORE_KEY) -
(Float)o1.getObjectField(SCORE_KEY));
+ final int result =
(int)((Float)o2.getObjectField(SCORE_KEY) -
(Float)o1.getObjectField(SCORE_KEY));
+ // never return zero. in a treeset it means overriding the
other enrichment.
+ return 0 != result
+ ? result
+ :
String.CASE_INSENSITIVE_ORDER.compare(o1.getField(NAME), o2.getField(NAME));
}
});
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits