You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2016/09/11 18:55:55 UTC
lucene-solr:branch_6_2: SOLR-9494: CollapseQParser's collectors
should override needsScores();
can trigger exceptions Also, field cscore was not needed.
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6_2 1578c036e -> 272ceb7c0
SOLR-9494: CollapseQParser's collectors should override needsScores(); can trigger exceptions
Also, field cscore was not needed.
(cherry picked from commit a029c8e)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/272ceb7c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/272ceb7c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/272ceb7c
Branch: refs/heads/branch_6_2
Commit: 272ceb7c03618b5343ac974e7d54673c8e658121
Parents: 1578c03
Author: David Smiley <ds...@apache.org>
Authored: Sun Sep 11 14:29:26 2016 -0400
Committer: David Smiley <ds...@apache.org>
Committed: Sun Sep 11 14:55:23 2016 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 10 ++++++++++
.../solr/search/CollapsingQParserPlugin.java | 18 ++++++++++++------
.../solr/search/TestCollapseQParserPlugin.java | 17 +++++++++++++++++
3 files changed, 39 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/272ceb7c/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 41e4d40..2ba1bf2 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -16,6 +16,16 @@ In this release, there is an example Solr server including a bundled
servlet container in the directory named "example".
See the Quick Start guide at http://lucene.apache.org/solr/quickstart.html
+
+================== 6.2.1 ==================
+
+Bug Fixes
+----------------------
+
+* SOLR-9494: Use of {!collapse} sometimes doesn't correctly return true for Collector.needsScores(), especially when the
+ query was cached. This can cause an exception when 'q' is a SpanQuery or potentially others. (David Smiley)
+
+
================== 6.2.0 ==================
Versions of Major Components
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/272ceb7c/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
index b9d292e..1d5bd58 100644
--- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
@@ -517,6 +517,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
}
}
+ @Override public boolean needsScores() { return true; }
+
@Override
protected void doSetNextReader(LeafReaderContext context) throws IOException {
this.contexts[context.ord] = context;
@@ -726,6 +728,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
}
+ @Override public boolean needsScores() { return true; }
+
@Override
protected void doSetNextReader(LeafReaderContext context) throws IOException {
this.contexts[context.ord] = context;
@@ -914,6 +918,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
return false;
}
+ @Override public boolean needsScores() { return needsScores || super.needsScores(); }
+
public void setScorer(Scorer scorer) {
this.collapseStrategy.setScorer(scorer);
}
@@ -1079,6 +1085,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
return false;
}
+ @Override public boolean needsScores() { return needsScores || super.needsScores(); }
+
public void setScorer(Scorer scorer) {
this.collapseStrategy.setScorer(scorer);
}
@@ -1696,7 +1704,6 @@ public class CollapsingQParserPlugin extends QParserPlugin {
private float[] ordVals;
private Map rcontext;
private final CollapseScore collapseScore = new CollapseScore();
- private final boolean cscore;
private float score;
public OrdValueSourceStrategy(int maxDoc,
@@ -1724,7 +1731,7 @@ public class CollapsingQParserPlugin extends QParserPlugin {
Arrays.fill(ordVals, Float.MAX_VALUE);
}
- this.cscore = collapseScore.setupIfNeeded(groupHeadSelector, rcontext);
+ collapseScore.setupIfNeeded(groupHeadSelector, rcontext);
if(this.needsScores) {
this.scores = new float[ords.length];
@@ -1745,7 +1752,7 @@ public class CollapsingQParserPlugin extends QParserPlugin {
this.boostDocs.add(globalDoc);
}
- if(needsScores || cscore) {
+ if (needsScores) {
this.score = scorer.score();
this.collapseScore.score = score;
}
@@ -2218,7 +2225,6 @@ public class CollapsingQParserPlugin extends QParserPlugin {
private FunctionValues functionValues;
private Map rcontext;
private final CollapseScore collapseScore = new CollapseScore();
- private final boolean cscore;
private float score;
private int index=-1;
@@ -2250,7 +2256,7 @@ public class CollapsingQParserPlugin extends QParserPlugin {
comp = new MinFloatComp();
}
- this.cscore = collapseScore.setupIfNeeded(groupHeadSelector, rcontext);
+ collapseScore.setupIfNeeded(groupHeadSelector, rcontext);
if(needsScores) {
this.scores = new float[size];
@@ -2273,7 +2279,7 @@ public class CollapsingQParserPlugin extends QParserPlugin {
return;
}
- if(needsScores || cscore) {
+ if (needsScores) {
this.score = scorer.score();
this.collapseScore.score = score;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/272ceb7c/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
index 6eca623..7c5fc4a 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
@@ -263,6 +263,23 @@ public class TestCollapseQParserPlugin extends SolrTestCaseJ4 {
}
+ @Test // https://issues.apache.org/jira/browse/SOLR-9494
+ public void testNeedsScoreBugFixed() throws Exception {
+ String[] doc = {"id","1", "group_s", "xyz", "text_ws", "hello xxx world"};
+ assertU(adoc(doc));
+ assertU(commit());
+
+ ModifiableSolrParams params = params(
+ "q", "{!surround df=text_ws} 2W(hello, world)", // a SpanQuery that matches
+ "fq", "{!collapse field=group_s}", // collapse on some field
+ // note: rows= whatever; doesn't matter
+ "facet", "true", // facet on something
+ "facet.field", "group_s"
+ );
+ assertQ(req(params));
+ assertQ(req(params)); // fails *second* time!
+ }
+
@Test
public void testMergeBoost() throws Exception {