lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r782325 - /lucene/solr/trunk/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
Date Sun, 07 Jun 2009 01:41:38 GMT
Author: yonik
Date: Sun Jun  7 01:41:38 2009
New Revision: 782325

URL: http://svn.apache.org/viewvc?rev=782325&view=rev
Log:
SOLR-1111: fix hashCode/equals for Sort in QueryElevationComponent by using singletons

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/handler/component/QueryElevationComponent.java

Modified: lucene/solr/trunk/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/component/QueryElevationComponent.java?rev=782325&r1=782324&r2=782325&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
Sun Jun  7 01:41:38 2009
@@ -99,6 +99,9 @@
     final BooleanQuery include;
     final Map<String,Integer> priority;
     
+    // use singletons so hashCode/equals on Sort will just work
+    final FieldComparatorSource comparatorSource;
+
     ElevationObj( String qstr, List<String> elevate, List<String> exclude ) throws
IOException
     {
       this.text = qstr;
@@ -124,6 +127,8 @@
           this.exclude[i] = new BooleanClause( tq, BooleanClause.Occur.MUST_NOT );
         }
       }
+
+      this.comparatorSource = new ElevationComparatorSource(priority);
     }
   }
   
@@ -348,7 +353,7 @@
       SortSpec sortSpec = rb.getSortSpec();
       if( sortSpec.getSort() == null ) {
         sortSpec.setSort( new Sort( new SortField[] {
-            new SortField(idField, new ElevationComparatorSource(booster.priority), false
),
+            new SortField(idField, booster.comparatorSource, false ),
             new SortField(null, SortField.SCORE, false)
         }));
       }
@@ -359,14 +364,12 @@
         ArrayList<SortField> sorts = new ArrayList<SortField>( current.length
+ 1 );
         // Perhaps force it to always sort by score
         if( force && current[0].getType() != SortField.SCORE ) {
-          sorts.add( new SortField(idField, 
-              new ElevationComparatorSource(booster.priority), false ) );
+          sorts.add( new SortField(idField, booster.comparatorSource, false ) );
           modify = true;
         }
         for( SortField sf : current ) {
           if( sf.getType() == SortField.SCORE ) {
-            sorts.add( new SortField(idField, 
-                new ElevationComparatorSource(booster.priority), sf.getReverse() ) );
+            sorts.add( new SortField(idField, booster.comparatorSource, sf.getReverse() )
);
             modify = true;
           }
           sorts.add( sf );
@@ -479,7 +482,7 @@
       }
 
       public int sortType() {
-        return SortField.INT;
+        return SortField.CUSTOM;
       }
 
       public Comparable value(int slot) {



Mime
View raw message