mirror of https://github.com/apache/lucene.git
SOLR-6835: ReRankQueryParserPlugin checks now whether the reRankQuery parameter is present and not empty
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1684904 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9756d6f948
commit
62c1481594
|
@ -121,6 +121,9 @@ Bug Fixes
|
||||||
* SOLR-7108: Change default query used by /admin/ping to not rely on other parameters such as query parser or
|
* SOLR-7108: Change default query used by /admin/ping to not rely on other parameters such as query parser or
|
||||||
default field. (ehatcher)
|
default field. (ehatcher)
|
||||||
|
|
||||||
|
* SOLR-6835: ReRankQueryParserPlugin checks now whether the reRankQuery parameter is present and not empty.
|
||||||
|
(帅广应, Marius Grama via shalin)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
* SOLR-7660: Avoid redundant 'exists' calls made to ZK while fetching cluster state updates. (shalin)
|
* SOLR-7660: Avoid redundant 'exists' calls made to ZK while fetching cluster state updates. (shalin)
|
||||||
|
|
|
@ -78,8 +78,10 @@ public class ReRankQParserPlugin extends QParserPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Query parse() throws SyntaxError {
|
public Query parse() throws SyntaxError {
|
||||||
|
|
||||||
String reRankQueryString = localParams.get("reRankQuery");
|
String reRankQueryString = localParams.get("reRankQuery");
|
||||||
|
if (reRankQueryString == null || reRankQueryString.trim().length() == 0) {
|
||||||
|
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "reRankQuery parameter is mandatory");
|
||||||
|
}
|
||||||
QParser reRankParser = QParser.getParser(reRankQueryString, null, req);
|
QParser reRankParser = QParser.getParser(reRankQueryString, null, req);
|
||||||
Query reRankQuery = reRankParser.parse();
|
Query reRankQuery = reRankParser.parse();
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,6 @@ import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import com.carrotsearch.hppc.IntOpenHashSet;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
|
public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
|
@ -517,9 +512,32 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
|
||||||
"//result/doc[1]/float[@name='id'][.='1.0']", //Elevated
|
"//result/doc[1]/float[@name='id'][.='1.0']", //Elevated
|
||||||
"//result/doc[2]/float[@name='id'][.='4.0']", //Elevated
|
"//result/doc[2]/float[@name='id'][.='4.0']", //Elevated
|
||||||
"//result/doc[3]/float[@name='id'][.='8.0']"); //Boosted during rerank.
|
"//result/doc[3]/float[@name='id'][.='8.0']"); //Boosted during rerank.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRerankQueryParsingShouldFailWithoutMandatoryReRankQueryParameter() throws Exception {
|
||||||
|
assertU(delQ("*:*"));
|
||||||
|
assertU(commit());
|
||||||
|
|
||||||
|
String[] doc = {"id", "1", "term_s", "YYYY", "group_s", "group1", "test_ti", "5", "test_tl", "10", "test_tf", "2000"};
|
||||||
|
assertU(adoc(doc));
|
||||||
|
assertU(commit());
|
||||||
|
String[] doc1 = {"id", "2", "term_s", "YYYY", "group_s", "group1", "test_ti", "50", "test_tl", "100", "test_tf", "200"};
|
||||||
|
assertU(adoc(doc1));
|
||||||
|
assertU(commit());
|
||||||
|
|
||||||
|
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||||
|
|
||||||
|
params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=200}");
|
||||||
|
params.add("q", "term_s:YYYY");
|
||||||
|
params.add("start", "0");
|
||||||
|
params.add("rows", "2");
|
||||||
|
|
||||||
|
try {
|
||||||
|
h.query(req(params));
|
||||||
|
fail("A syntax error should be thrown when reRankQuery parameter is not specified");
|
||||||
|
} catch (SolrException e) {
|
||||||
|
assertTrue(e.code() == SolrException.ErrorCode.BAD_REQUEST.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue