lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject svn commit: r1718011 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/search/ lucene/grouping/ lucene/grouping/src/java/org/apache/lucene/search/grouping/ lucene/grouping/src/java/org/apache/lucene/sea...
Date Fri, 04 Dec 2015 19:33:34 GMT
Author: dsmiley
Date: Fri Dec  4 19:33:33 2015
New Revision: 1718011

URL: http://svn.apache.org/viewvc?rev=1718011&view=rev
Log:
LUCENE-6912: Grouping's Collectors now calculate a needsScores() instead of always 'true'.
In core, CachingCollector should have always returned true when scores are cached (small bug).

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/lucene/core/   (props changed)
    lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/   (props changed)
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractAllGroupsCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractDistinctValuesCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractFirstPassGroupingCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractGroupFacetCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractSecondPassGroupingCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionAllGroupHeadsCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionAllGroupsCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionDistinctValuesCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionFirstPassGroupingCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionSecondPassGroupingCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupHeadsCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupsCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermDistinctValuesCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermFirstPassGroupingCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermGroupFacetCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermSecondPassGroupingCollector.java
    lucene/dev/branches/branch_5x/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java

Modified: lucene/dev/branches/branch_5x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/CHANGES.txt?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/lucene/CHANGES.txt Fri Dec  4 19:33:33 2015
@@ -17,6 +17,9 @@ Optimizations
   particular to rewrite queries that look like: "+*:* #filter" to a
   "ConstantScore(filter)". (Adrien Grand)
 
+* LUCENE-6912: Grouping's Collectors now calculate a response to needsScores()
+  instead of always 'true'. (David Smiley)
+
 Bug Fixes
 
 * LUCENE-6918: LRUQueryCache.onDocIdSetEviction is only called when at least

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java
Fri Dec  4 19:33:33 2015
@@ -99,6 +99,9 @@ public abstract class CachingCollector e
       return new NoScoreCachingLeafCollector(in, maxDocsToCache);
     }
 
+    // note: do *not* override needScore to say false. Just because we aren't caching the
score doesn't mean the
+    //   wrapped collector doesn't need it to do its job.
+
     public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
       postCollection();
       final LeafCollector in = this.in.getLeafCollector(context);
@@ -177,6 +180,13 @@ public abstract class CachingCollector e
       scores.add(coll.cachedScores());
     }
 
+    /** Ensure the scores are collected so they can be replayed, even if the wrapped collector
doesn't need them. */
+    @Override
+    public boolean needsScores() {
+      return true;
+    }
+
+    @Override
     protected void collect(LeafCollector collector, int i) throws IOException {
       final int[] docs = this.docs.get(i);
       final float[] scores = this.scores.get(i);
@@ -189,7 +199,6 @@ public abstract class CachingCollector e
         collector.collect(scorer.doc);
       }
     }
-
   }
 
   private class NoScoreCachingLeafCollector extends FilterLeafCollector {

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractAllGroupsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractAllGroupsCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractAllGroupsCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractAllGroupsCollector.java
Fri Dec  4 19:33:33 2015
@@ -61,4 +61,8 @@ public abstract class AbstractAllGroupsC
   @Override
   public void setScorer(Scorer scorer) throws IOException {}
 
+  @Override
+  public boolean needsScores() {
+    return false; // the result is unaffected by relevancy
+  }
 }
\ No newline at end of file

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractDistinctValuesCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractDistinctValuesCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractDistinctValuesCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractDistinctValuesCollector.java
Fri Dec  4 19:33:33 2015
@@ -52,4 +52,9 @@ public abstract class AbstractDistinctVa
     }
   }
 
+  @Override
+  public boolean needsScores() {
+    return false; // not needed to fetch all values
+  }
+
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractFirstPassGroupingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractFirstPassGroupingCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractFirstPassGroupingCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractFirstPassGroupingCollector.java
Fri Dec  4 19:33:33 2015
@@ -39,6 +39,7 @@ abstract public class AbstractFirstPassG
   private final LeafFieldComparator[] leafComparators;
   private final int[] reversed;
   private final int topNGroups;
+  private final boolean needsScores;
   private final HashMap<GROUP_VALUE_TYPE, CollectedSearchGroup<GROUP_VALUE_TYPE>>
groupMap;
   private final int compIDXEnd;
 
@@ -70,7 +71,7 @@ abstract public class AbstractFirstPassG
     // and specialize it?
 
     this.topNGroups = topNGroups;
-
+    this.needsScores = groupSort.needsScores();
     final SortField[] sortFields = groupSort.getSort();
     comparators = new FieldComparator[sortFields.length];
     leafComparators = new LeafFieldComparator[sortFields.length];
@@ -88,6 +89,11 @@ abstract public class AbstractFirstPassG
     groupMap = new HashMap<>(topNGroups);
   }
 
+  @Override
+  public boolean needsScores() {
+    return needsScores;
+  }
+
   /**
    * Returns top groups, starting from offset.  This may
    * return null, if no groups were collected, or if the

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractGroupFacetCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractGroupFacetCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractGroupFacetCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractGroupFacetCollector.java
Fri Dec  4 19:33:33 2015
@@ -109,6 +109,11 @@ public abstract class AbstractGroupFacet
   public void setScorer(Scorer scorer) throws IOException {
   }
 
+  @Override
+  public boolean needsScores() {
+    return false;
+  }
+
   /**
    * The grouped facet result. Containing grouped facet entries, total count and total missing
count.
    */

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractSecondPassGroupingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractSecondPassGroupingCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractSecondPassGroupingCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/AbstractSecondPassGroupingCollector.java
Fri Dec  4 19:33:33 2015
@@ -40,12 +40,14 @@ import java.util.Objects;
  */
 public abstract class AbstractSecondPassGroupingCollector<GROUP_VALUE_TYPE> extends
SimpleCollector {
 
-  protected final Map<GROUP_VALUE_TYPE, SearchGroupDocs<GROUP_VALUE_TYPE>> groupMap;
-  private final int maxDocsPerGroup;
-  protected SearchGroupDocs<GROUP_VALUE_TYPE>[] groupDocs;
   private final Collection<SearchGroup<GROUP_VALUE_TYPE>> groups;
-  private final Sort withinGroupSort;
   private final Sort groupSort;
+  private final Sort withinGroupSort;
+  private final int maxDocsPerGroup;
+  private final boolean needsScores;
+  protected final Map<GROUP_VALUE_TYPE, SearchGroupDocs<GROUP_VALUE_TYPE>> groupMap;
+
+  protected SearchGroupDocs<GROUP_VALUE_TYPE>[] groupDocs;
 
   private int totalHitCount;
   private int totalGroupedHitCount;
@@ -59,12 +61,13 @@ public abstract class AbstractSecondPass
       throw new IllegalArgumentException("no groups to collect (groups is empty)");
     }
 
+    this.groups = Objects.requireNonNull(groups);
     this.groupSort = Objects.requireNonNull(groupSort);
     this.withinGroupSort = Objects.requireNonNull(withinGroupSort);
-    this.groups = Objects.requireNonNull(groups);
     this.maxDocsPerGroup = maxDocsPerGroup;
-    this.groupMap = new HashMap<>(groups.size());
+    this.needsScores = getScores || getMaxScores || withinGroupSort.needsScores();
 
+    this.groupMap = new HashMap<>(groups.size());
     for (SearchGroup<GROUP_VALUE_TYPE> group : groups) {
       //System.out.println("  prep group=" + (group.groupValue == null ? "null" : group.groupValue.utf8ToString()));
       final TopDocsCollector<?> collector;
@@ -80,6 +83,11 @@ public abstract class AbstractSecondPass
   }
 
   @Override
+  public boolean needsScores() {
+    return needsScores;
+  }
+
+  @Override
   public void setScorer(Scorer scorer) throws IOException {
     for (SearchGroupDocs<GROUP_VALUE_TYPE> group : groupMap.values()) {
       group.leafCollector.setScorer(scorer);

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionAllGroupHeadsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionAllGroupHeadsCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionAllGroupHeadsCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionAllGroupHeadsCollector.java
Fri Dec  4 19:33:33 2015
@@ -155,6 +155,6 @@ public class FunctionAllGroupHeadsCollec
 
   @Override
   public boolean needsScores() {
-    return true; // TODO, maybe we don't: e.g. return sortWithinGroup.needsScores()
+    return sortWithinGroup.needsScores();
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionAllGroupsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionAllGroupsCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionAllGroupsCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionAllGroupsCollector.java
Fri Dec  4 19:33:33 2015
@@ -79,9 +79,5 @@ public class FunctionAllGroupsCollector
     filler = values.getValueFiller();
     mval = filler.getValue();
   }
-  
-  @Override
-  public boolean needsScores() {
-    return true; // TODO, maybe we don't?
-  }
+
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionDistinctValuesCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionDistinctValuesCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionDistinctValuesCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionDistinctValuesCollector.java
Fri Dec  4 19:33:33 2015
@@ -89,9 +89,5 @@ public class FunctionDistinctValuesColle
     }
 
   }
-  
-  @Override
-  public boolean needsScores() {
-    return true; // TODO, maybe we don't?
-  }
+
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionFirstPassGroupingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionFirstPassGroupingCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionFirstPassGroupingCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionFirstPassGroupingCollector.java
Fri Dec  4 19:33:33 2015
@@ -84,8 +84,4 @@ public class FunctionFirstPassGroupingCo
     mval = filler.getValue();
   }
 
-  @Override
-  public boolean needsScores() {
-    return true; // TODO, maybe we don't?
-  }
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionSecondPassGroupingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionSecondPassGroupingCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionSecondPassGroupingCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/function/FunctionSecondPassGroupingCollector.java
Fri Dec  4 19:33:33 2015
@@ -78,8 +78,4 @@ public class FunctionSecondPassGroupingC
     mval = filler.getValue();
   }
 
-  @Override
-  public boolean needsScores() {
-    return true; // TODO, maybe we don't?
-  }
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupHeadsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupHeadsCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupHeadsCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupHeadsCollector.java
Fri Dec  4 19:33:33 2015
@@ -171,6 +171,11 @@ public abstract class TermAllGroupHeadsC
     }
 
     @Override
+    public boolean needsScores() {
+      return sortWithinGroup.needsScores();
+    }
+
+    @Override
     public void setScorer(Scorer scorer) throws IOException {
       this.scorer = scorer;
       for (GroupHead groupHead : groups.values()) {
@@ -250,6 +255,11 @@ public abstract class TermAllGroupHeadsC
     }
 
     @Override
+    public boolean needsScores() {
+      return true;
+    }
+
+    @Override
     public void setScorer(Scorer scorer) throws IOException {
       this.scorer = scorer;
     }
@@ -410,6 +420,11 @@ public abstract class TermAllGroupHeadsC
     }
 
     @Override
+    public boolean needsScores() {
+      return false;
+    }
+
+    @Override
     public void setScorer(Scorer scorer) throws IOException {
     }
 
@@ -541,6 +556,11 @@ public abstract class TermAllGroupHeadsC
     }
 
     @Override
+    public boolean needsScores() {
+      return true;
+    }
+
+    @Override
     public void setScorer(Scorer scorer) throws IOException {
       this.scorer = scorer;
     }
@@ -626,9 +646,5 @@ public abstract class TermAllGroupHeadsC
     }
 
   }
-  
-  @Override
-  public boolean needsScores() {
-    return true; // TODO, maybe we don't?
-  }
+
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupsCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupsCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupsCollector.java
Fri Dec  4 19:33:33 2015
@@ -117,9 +117,5 @@ public class TermAllGroupsCollector exte
       }
     }
   }
-  
-  @Override
-  public boolean needsScores() {
-    return true; // TODO, maybe we don't?
-  }
+
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermDistinctValuesCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermDistinctValuesCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermDistinctValuesCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermDistinctValuesCollector.java
Fri Dec  4 19:33:33 2015
@@ -141,8 +141,4 @@ public class TermDistinctValuesCollector
     }
   }
 
-  @Override
-  public boolean needsScores() {
-    return true; // TODO, maybe we don't?
-  }
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermFirstPassGroupingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermFirstPassGroupingCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermFirstPassGroupingCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermFirstPassGroupingCollector.java
Fri Dec  4 19:33:33 2015
@@ -91,9 +91,5 @@ public class TermFirstPassGroupingCollec
     super.doSetNextReader(readerContext);
     index = DocValues.getSorted(readerContext.reader(), groupField);
   }
-  
-  @Override
-  public boolean needsScores() {
-    return true; // TODO, maybe we don't?
-  }
+
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermGroupFacetCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermGroupFacetCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermGroupFacetCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermGroupFacetCollector.java
Fri Dec  4 19:33:33 2015
@@ -75,11 +75,6 @@ public abstract class TermGroupFacetColl
     groupedFacetHits = new ArrayList<>(initialSize);
     segmentGroupedFacetHits = new SentinelIntSet(initialSize, Integer.MIN_VALUE);
   }
-  
-  @Override
-  public boolean needsScores() {
-    return true; // TODO, maybe we don't?
-  }
 
   // Implementation for single valued facet fields.
   static class SV extends TermGroupFacetCollector {

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermSecondPassGroupingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermSecondPassGroupingCollector.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermSecondPassGroupingCollector.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermSecondPassGroupingCollector.java
Fri Dec  4 19:33:33 2015
@@ -77,9 +77,5 @@ public class TermSecondPassGroupingColle
     }
     return null;
   }
-  
-  @Override
-  public boolean needsScores() {
-    return true; // TODO, maybe we don't?
-  }
+
 }

Modified: lucene/dev/branches/branch_5x/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java?rev=1718011&r1=1718010&r2=1718011&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
Fri Dec  4 19:33:33 2015
@@ -837,22 +837,9 @@ public class TestGrouping extends Lucene
         final boolean getMaxScores = random().nextBoolean();
         final Sort groupSort = getRandomSort();
         //final Sort groupSort = new Sort(new SortField[] {new SortField("sort1", SortField.STRING),
new SortField("id", SortField.INT)});
-        // TODO: also test null (= sort by relevance)
         final Sort docSort = getRandomSort();
         
-        for(SortField sf : docSort.getSort()) {
-          if (sf.getType() == SortField.Type.SCORE) {
-            getScores = true;
-            break;
-          }
-        }
-        
-        for(SortField sf : groupSort.getSort()) {
-          if (sf.getType() == SortField.Type.SCORE) {
-            getScores = true;
-            break;
-          }
-        }
+        getScores |= (groupSort.needsScores() || docSort.needsScores());
         
         final int topNGroups = TestUtil.nextInt(random(), 1, 30);
         //final int topNGroups = 10;
@@ -863,7 +850,7 @@ public class TestGrouping extends Lucene
         
         final int docOffset = TestUtil.nextInt(random(), 0, docsPerGroup - 1);
         //final int docOffset = 0;
-        
+
         final boolean doCache = random().nextBoolean();
         final boolean doAllGroups = random().nextBoolean();
         if (VERBOSE) {
@@ -1170,7 +1157,7 @@ public class TestGrouping extends Lucene
       System.out.println("TEST: " + subSearchers.length + " shards: " + Arrays.toString(subSearchers)
+ " canUseIDV=" + canUseIDV);
     }
     // Run 1st pass collector to get top groups per shard
-    final Weight w = topSearcher.createNormalizedWeight(query, true);
+    final Weight w = topSearcher.createNormalizedWeight(query, getScores);
     final List<Collection<SearchGroup<BytesRef>>> shardGroups = new ArrayList<>();
     List<AbstractFirstPassGroupingCollector<?>> firstPassGroupingCollectors =
new ArrayList<>();
     AbstractFirstPassGroupingCollector<?> firstPassCollector = null;



Mime
View raw message