Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-4992: CustomScoreQuery does not work with arbitrary queries: scoringQueries must match every document

Robert Muir884b73c5ecec
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 80f585addb5..5dfd2612006 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -106,6 +106,10 @@ Bug Fixes
* LUCENE-4996: Ensure DocInverterPerField always includes field name
in exception messages. (Markus Jelsma via Robert Muir)
+* LUCENE-4992: Fix constructor of CustomScoreQuery to take FunctionQuery
+ for scoringQueries. Instead use QueryValueSource to safely wrap arbitrary
+ queries and use them with CustomScoreQuery. (John Wang, Robert Muir)
+
Optimizations
* LUCENE-4936: Improve numeric doc values compression in case all values share
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
index 5cf2c740421..602fa8b034c 100755
--- a/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
@@ -58,7 +58,7 @@ public class CustomScoreQuery extends Query {
* @param subQuery the sub query whose scored is being customized. Must not be null.
*/
public CustomScoreQuery(Query subQuery) {
- this(subQuery, new Query[0]);
+ this(subQuery, new FunctionQuery[0]);
}
/**
@@ -67,9 +67,9 @@ public class CustomScoreQuery extends Query {
* @param scoringQuery a value source query whose scores are used in the custom score
* computation. This parameter is optional - it can be null.
*/
- public CustomScoreQuery(Query subQuery, Query scoringQuery) {
+ public CustomScoreQuery(Query subQuery, FunctionQuery scoringQuery) {
this(subQuery, scoringQuery!=null ? // don't want an array that contains a single null..
- new Query[] {scoringQuery} : new Query[0]);
+ new FunctionQuery[] {scoringQuery} : new FunctionQuery[0]);
}
/**
@@ -78,7 +78,7 @@ public class CustomScoreQuery extends Query {
* @param scoringQueries value source queries whose scores are used in the custom score
* computation. This parameter is optional - it can be null or even an empty array.
*/
- public CustomScoreQuery(Query subQuery, Query... scoringQueries) {
+ public CustomScoreQuery(Query subQuery, FunctionQuery... scoringQueries) {
this.subQuery = subQuery;
this.scoringQueries = scoringQueries !=null?
scoringQueries : new Query[0];