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

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1485040 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-05-22 03:35:22 +00:00
parent 6a9fc2aa55
commit 884b73c5ec
2 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -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];