This is an automated email from the ASF dual-hosted git repository.
gerlowskija pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 46feb7775a0 SOLR-18332: More qt-removal from tests, rd 3 (#4721)
46feb7775a0 is described below
commit 46feb7775a0ddbe261c9bd14c27a338e7c0a2d47
Author: Jason Gerlowski <[email protected]>
AuthorDate: Wed Aug 12 20:44:11 2026 -0400
SOLR-18332: More qt-removal from tests, rd 3 (#4721)
The 'qt' parameter and several related methods in SolrJ are deprecated.
This deprecation may not stick, but it's still worth minimizing use of this
feature as much as possible.
Many tests rely on it unnecessarily; this PR is one in a number of batches
slowly removing these usages. This one focuses on solr-core tests that
dispatch through the req()/assertQ/assertJQ/assertQEx helpers; it replaces
qt usage by instead using a new `reqWithPath(...)` helper to ensure the
SolrQueryRequest has the correct path.
---
.../test/org/apache/solr/TestCrossCoreJoin.java | 3 +-
.../solr/handler/MoreLikeThisHandlerTest.java | 19 +-
.../component/QueryElevationComponentTest.java | 684 +++++++++++----------
.../handler/component/TermVectorComponentTest.java | 60 +-
.../solr/handler/component/TermsComponentTest.java | 225 ++++---
.../component/TestMatchedQueriesComponent.java | 197 +++---
.../org/apache/solr/search/TestBlockCollapse.java | 339 ++++++----
.../solr/search/TestCollapseQParserPlugin.java | 69 +--
.../solr/search/TestReRankQParserPlugin.java | 21 +-
.../src/java/org/apache/solr/SolrTestCaseJ4.java | 43 +-
.../src/java/org/apache/solr/util/TestHarness.java | 4 +-
11 files changed, 916 insertions(+), 748 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java
b/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java
index 1d8f2308c6b..1a42e2781e5 100644
--- a/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java
+++ b/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java
@@ -151,8 +151,7 @@ public class TestCrossCoreJoin extends SolrTestCaseJ4 {
"/response=={'numFound':3,'start':0,'numFoundExact':true,'docs':[{'id':'1'},{'id':'4'},{'id':'5'}]}");
assertJQ(
- req(
- "qt",
+ reqWithPath(
"/export",
"q",
joinPrefix + " from=dept_id_s to=dept_s
fromIndex=fromCore}cat:dev",
diff --git
a/solr/core/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java
b/solr/core/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java
index 341e406d17c..661dd4da794 100644
--- a/solr/core/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java
@@ -221,16 +221,14 @@ public class MoreLikeThisHandlerTest extends
SolrTestCaseJ4 {
// test that qparser plugins work w/ the MoreLikeThisHandler
params.set(CommonParams.Q, "{!field f=id}44");
- try (SolrQueryRequest mltreq = new SolrQueryRequestBase(core, params)) {
- assertQ(null, "/mlt", mltreq, "//result/doc[1]/str[@name='id'][.='45']");
+ try (SolrQueryRequest mltreq = withPath("/mlt", new
SolrQueryRequestBase(core, params))) {
+ assertQ(mltreq, "//result/doc[1]/str[@name='id'][.='45']");
}
// test that debugging works (test for MoreLikeThis*Handler*)
params.set(CommonParams.DEBUG_QUERY, "true");
- try (SolrQueryRequest mltreq = new SolrQueryRequestBase(core, params)) {
+ try (SolrQueryRequest mltreq = withPath("/mlt", new
SolrQueryRequestBase(core, params))) {
assertQ(
- null,
- "/mlt",
mltreq,
"//result/doc[1]/str[@name='id'][.='45']",
"//lst[@name='debug']/lst[@name='explain']");
@@ -238,20 +236,16 @@ public class MoreLikeThisHandlerTest extends
SolrTestCaseJ4 {
params.set(FacetComponent.COMPONENT_NAME, "true");
params.set("facet.field", "name");
- try (SolrQueryRequest mltreq = new SolrQueryRequestBase(core, params)) {
+ try (SolrQueryRequest mltreq = withPath("/mlt", new
SolrQueryRequestBase(core, params))) {
assertQ(
- null,
- "/mlt",
mltreq,
"//result/doc[1]/str[@name='id'][.='45']",
"//lst[@name='facet_counts']/lst[@name='facet_fields']/lst[@name='name']/int[@name='George'][.='1']");
}
params.set("facet.field", "{!ex=tg}name");
params.set("fq", "{!tag=tg}name:George");
- try (SolrQueryRequest mltreq = new SolrQueryRequestBase(core, params)) {
+ try (SolrQueryRequest mltreq = withPath("/mlt", new
SolrQueryRequestBase(core, params))) {
assertQ(
- null,
- "/mlt",
mltreq,
"//result/doc[1]/str[@name='id'][.='45']",
"//lst[@name='facet_counts']/lst[@name='facet_fields']/lst[@name='name']/int[@name='George'][.='1']");
@@ -279,12 +273,11 @@ public class MoreLikeThisHandlerTest extends
SolrTestCaseJ4 {
try (SolrQueryRequestBase req = new SolrQueryRequestBase(core, params) {})
{
req.setContentStreams(List.of(new ContentStreamBase.StringStream("bbb",
"zzz")));
+ req.getContext().put(CommonParams.PATH, "/mlt");
// Make sure we have terms from both fields in the interestingTerms
array and all documents
// have been retrieved as matching.
assertQ(
- null,
- "/mlt",
req,
"//lst[@name = 'interestingTerms']/float[@name = 'subword:bbb']",
"//lst[@name = 'interestingTerms']/float[@name = 'name:bbb']",
diff --git
a/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
b/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
index aa2b70c0132..5079fb9970f 100644
---
a/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
+++
b/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
@@ -118,13 +118,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"",
- req(
- CommonParams.Q,
- "AAAA",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elevated]"),
+ reqWithPath("/elevate", CommonParams.Q, "AAAA", CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='7']",
"//result/doc[2]/str[@name='id'][.='9']",
@@ -156,10 +150,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// elevated docs 1, 2, and 3 are returned even though our query "ZZZZ"
doesn't match them
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath("/elevate", CommonParams.Q, "ZZZZ", CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='2']",
@@ -172,11 +163,14 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// exclude docs 1 and 3 even though those docs are elevated
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "str_s:b"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "str_s:b"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='2']",
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
@@ -186,12 +180,16 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// docs
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!tag=test1,test2}str_s:b",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test3"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!tag=test1,test2}str_s:b",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test3"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='2']",
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
@@ -200,12 +198,16 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// behavior as above; the filter still takes effect on the elevated docs
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!tag=test1,test2}str_s:b",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, ","),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!tag=test1,test2}str_s:b",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ ","),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='2']",
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
@@ -215,12 +217,16 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// the original filter
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!tag=test1,test2}str_s:b",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test0,test2,test4"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!tag=test1,test2}str_s:b",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test0,test2,test4"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='2']",
@@ -233,12 +239,16 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// this case, the main query); nor does including empty values in the
list of tags to exclude
assertQ(
"",
- req(
- CommonParams.Q, "{!tag=test0}ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!tag=test1,test1,test2,test2}str_s:b",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
"test0,test0,test2,test2,test4,test4,,,"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "{!tag=test0}ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!tag=test1,test1,test2,test2}str_s:b",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test0,test0,test2,test2,test4,test4,,,"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='2']",
@@ -250,14 +260,20 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// we can exclude some filters while leaving others in place
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!tag=test1}id:10",
- CommonParams.FQ, "{!tag=test2}str_s:b",
- CommonParams.FQ, "{!tag=test3}id:11",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test1,test3"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!tag=test1}id:10",
+ CommonParams.FQ,
+ "{!tag=test2}str_s:b",
+ CommonParams.FQ,
+ "{!tag=test3}id:11",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test1,test3"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='2']",
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
@@ -265,14 +281,20 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// when filters are marked as cache=false, tag exclusion works the same
as before
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!tag=test1 cache=false}id:10",
- CommonParams.FQ, "{!tag=test2 cache=false}str_s:b",
- CommonParams.FQ, "{!tag=test3 cache=false}id:11",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test1,test3"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!tag=test1 cache=false}id:10",
+ CommonParams.FQ,
+ "{!tag=test2 cache=false}str_s:b",
+ CommonParams.FQ,
+ "{!tag=test3 cache=false}id:11",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test1,test3"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='2']",
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
@@ -280,14 +302,20 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// we can apply the same tag to two different filters
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!tag=test1}id:10",
- CommonParams.FQ, "{!tag=test2}str_s:b",
- CommonParams.FQ, "{!tag=test1}id:11",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test1,test3"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!tag=test1}id:10",
+ CommonParams.FQ,
+ "{!tag=test2}str_s:b",
+ CommonParams.FQ,
+ "{!tag=test1}id:11",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test1,test3"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='2']",
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
@@ -295,13 +323,18 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// we can use filter() syntax inside fq's that are tagged for exclusion
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!tag=test1}+filter(id:10) +filter(id:11)",
- CommonParams.FQ, "{!tag=test2}filter(str_s:b)",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test1"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!tag=test1}+filter(id:10) +filter(id:11)",
+ CommonParams.FQ,
+ "{!tag=test2}filter(str_s:b)",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test1"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='2']",
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
@@ -310,10 +343,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// if we search for MMMM we should get one match; no documents are
elevated for this query
assertQ(
"",
- req(
- CommonParams.Q, "MMMM",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath("/elevate", CommonParams.Q, "MMMM", CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='4']",
"//result/doc[1]/bool[@name='[elevated]'][.='false']");
@@ -321,11 +351,14 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// if we add fq=str_s:b, our one document that matches MMMM will be
filtered out
assertQ(
"",
- req(
- CommonParams.Q, "MMMM",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "str_s:b"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "MMMM",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "str_s:b"),
"//*[@numFound='0']");
// if we tag the filter and exclude it, we should see the same behavior
as before; filters are
@@ -333,23 +366,30 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// subject to the filter
assertQ(
"",
- req(
- CommonParams.Q, "MMMM",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!tag=test1}str_s:b",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test1"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "MMMM",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!tag=test1}str_s:b",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test1"),
"//*[@numFound='0']");
// the next few assertions confirm that collapsing works as expected
when filters are
// excluded; first, confirm that when collapsing, all elevated docs are
visible by default
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!collapse field=str_s sort='score desc'}"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!collapse field=str_s sort='score desc'}"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='2']",
@@ -361,12 +401,16 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// when collapsing, an added filter has the expected effect
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!collapse field=str_s sort='score desc'}",
- CommonParams.FQ, "str_s:b"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!collapse field=str_s sort='score desc'}",
+ CommonParams.FQ,
+ "str_s:b"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='2']",
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
@@ -375,13 +419,18 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// elevated documents
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!collapse field=str_s sort='score desc'}",
- CommonParams.FQ, "{!tag=test1}str_s:b",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test1"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!collapse field=str_s sort='score desc'}",
+ CommonParams.FQ,
+ "{!tag=test1}str_s:b",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test1"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='2']",
@@ -394,13 +443,18 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// user should be informed
assertQEx(
"tagging a collapse filter for exclusion should lead to a
BAD_REQUEST",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!collapse tag=test1 field=str_s sort='score
desc'}",
- CommonParams.FQ, "{!tag=test2}str_s:b",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test1,test2"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!collapse tag=test1 field=str_s sort='score desc'}",
+ CommonParams.FQ,
+ "{!tag=test2}str_s:b",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test1,test2"),
SolrException.ErrorCode.BAD_REQUEST);
// if a function range query is provided as a filter, it can be tagged
for exclusion;
@@ -410,13 +464,18 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// behavior
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CommonParams.FL, "id, score, [elevated]",
- CommonParams.FQ, "{!frange tag=test1 l=100 cache=false
cost=200}5.0",
- CommonParams.FQ, "{!tag=test2}str_s:b",
- QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test1,test2"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CommonParams.FL,
+ "id, score, [elevated]",
+ CommonParams.FQ,
+ "{!frange tag=test1 l=100 cache=false cost=200}5.0",
+ CommonParams.FQ,
+ "{!tag=test2}str_s:b",
+ QueryElevationParams.ELEVATE_EXCLUDE_TAGS,
+ "test1,test2"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='2']",
@@ -454,7 +513,6 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
try (SolrQueryRequest request =
req(
CommonParams.Q, "ZZZZ1",
- CommonParams.QT, "/elevate",
CommonParams.DF, "text",
CommonParams.FL, "id, score, [elevated]",
CommonParams.FQ, "str_s:A",
@@ -524,7 +582,6 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
try (SolrQueryRequest request =
req(
CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
CommonParams.DF, "text",
CommonParams.FL, "id, score, [elevated]",
CommonParams.FQ, "str_s:A",
@@ -677,15 +734,22 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"non-elevated group query",
- req(
- CommonParams.Q, "AAAA",
- CommonParams.QT, "/elevate",
- GroupParams.GROUP_FIELD, "str_s",
- GroupParams.GROUP, "true",
- GroupParams.GROUP_TOTAL_COUNT, "true",
- GroupParams.GROUP_LIMIT, "100",
- QueryElevationParams.ENABLE, "false",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "AAAA",
+ GroupParams.GROUP_FIELD,
+ "str_s",
+ GroupParams.GROUP,
+ "true",
+ GroupParams.GROUP_TOTAL_COUNT,
+ "true",
+ GroupParams.GROUP_LIMIT,
+ "100",
+ QueryElevationParams.ENABLE,
+ "false",
+ CommonParams.FL,
+ "id, score, [elevated]"),
"//*[@name='ngroups'][.='3']",
"//*[@name='matches'][.='6']",
groups + "/lst[1]//doc[1]/str[@name='id'][.='6']",
@@ -703,14 +767,20 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"elevated group query",
- req(
- CommonParams.Q, "AAAA",
- CommonParams.QT, "/elevate",
- GroupParams.GROUP_FIELD, "str_s",
- GroupParams.GROUP, "true",
- GroupParams.GROUP_TOTAL_COUNT, "true",
- GroupParams.GROUP_LIMIT, "100",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "AAAA",
+ GroupParams.GROUP_FIELD,
+ "str_s",
+ GroupParams.GROUP,
+ "true",
+ GroupParams.GROUP_TOTAL_COUNT,
+ "true",
+ GroupParams.GROUP_LIMIT,
+ "100",
+ CommonParams.FL,
+ "id, score, [elevated]"),
"//*[@name='ngroups'][.='3']",
"//*[@name='matches'][.='6']",
groups + "/lst[1]//doc[1]/str[@name='id'][.='7']",
@@ -728,15 +798,22 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"non-elevated because sorted group query",
- req(
- CommonParams.Q, "AAAA",
- CommonParams.QT, "/elevate",
- CommonParams.SORT, "id asc",
- GroupParams.GROUP_FIELD, "str_s",
- GroupParams.GROUP, "true",
- GroupParams.GROUP_TOTAL_COUNT, "true",
- GroupParams.GROUP_LIMIT, "100",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "AAAA",
+ CommonParams.SORT,
+ "id asc",
+ GroupParams.GROUP_FIELD,
+ "str_s",
+ GroupParams.GROUP,
+ "true",
+ GroupParams.GROUP_TOTAL_COUNT,
+ "true",
+ GroupParams.GROUP_LIMIT,
+ "100",
+ CommonParams.FL,
+ "id, score, [elevated]"),
"//*[@name='ngroups'][.='3']",
"//*[@name='matches'][.='6']",
groups + "/lst[1]//doc[1]/str[@name='id'][.='2']",
@@ -754,16 +831,24 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"force-elevated sorted group query",
- req(
- CommonParams.Q, "AAAA",
- CommonParams.QT, "/elevate",
- CommonParams.SORT, "id asc",
- QueryElevationParams.FORCE_ELEVATION, "true",
- GroupParams.GROUP_FIELD, "str_s",
- GroupParams.GROUP, "true",
- GroupParams.GROUP_TOTAL_COUNT, "true",
- GroupParams.GROUP_LIMIT, "100",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "AAAA",
+ CommonParams.SORT,
+ "id asc",
+ QueryElevationParams.FORCE_ELEVATION,
+ "true",
+ GroupParams.GROUP_FIELD,
+ "str_s",
+ GroupParams.GROUP,
+ "true",
+ GroupParams.GROUP_TOTAL_COUNT,
+ "true",
+ GroupParams.GROUP_LIMIT,
+ "100",
+ CommonParams.FL,
+ "id, score, [elevated]"),
"//*[@name='ngroups'][.='3']",
"//*[@name='matches'][.='6']",
groups + "/lst[1]//doc[1]/str[@name='id'][.='7']",
@@ -781,16 +866,24 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"non-elevated because of sort within group query",
- req(
- CommonParams.Q, "AAAA",
- CommonParams.QT, "/elevate",
- CommonParams.SORT, "id asc",
- GroupParams.GROUP_SORT, "id desc",
- GroupParams.GROUP_FIELD, "str_s",
- GroupParams.GROUP, "true",
- GroupParams.GROUP_TOTAL_COUNT, "true",
- GroupParams.GROUP_LIMIT, "100",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "AAAA",
+ CommonParams.SORT,
+ "id asc",
+ GroupParams.GROUP_SORT,
+ "id desc",
+ GroupParams.GROUP_FIELD,
+ "str_s",
+ GroupParams.GROUP,
+ "true",
+ GroupParams.GROUP_TOTAL_COUNT,
+ "true",
+ GroupParams.GROUP_LIMIT,
+ "100",
+ CommonParams.FL,
+ "id, score, [elevated]"),
"//*[@name='ngroups'][.='3']",
"//*[@name='matches'][.='6']",
groups + "/lst[1]//doc[1]/str[@name='id'][.='22']",
@@ -808,17 +901,26 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"force elevated sort within sorted group query",
- req(
- CommonParams.Q, "AAAA",
- CommonParams.QT, "/elevate",
- CommonParams.SORT, "id asc",
- GroupParams.GROUP_SORT, "id desc",
- QueryElevationParams.FORCE_ELEVATION, "true",
- GroupParams.GROUP_FIELD, "str_s",
- GroupParams.GROUP, "true",
- GroupParams.GROUP_TOTAL_COUNT, "true",
- GroupParams.GROUP_LIMIT, "100",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "AAAA",
+ CommonParams.SORT,
+ "id asc",
+ GroupParams.GROUP_SORT,
+ "id desc",
+ QueryElevationParams.FORCE_ELEVATION,
+ "true",
+ GroupParams.GROUP_FIELD,
+ "str_s",
+ GroupParams.GROUP,
+ "true",
+ GroupParams.GROUP_TOTAL_COUNT,
+ "true",
+ GroupParams.GROUP_LIMIT,
+ "100",
+ CommonParams.FL,
+ "id, score, [elevated]"),
"//*[@name='ngroups'][.='3']",
"//*[@name='matches'][.='6']",
groups + "/lst[1]//doc[1]/str[@name='id'][.='7']",
@@ -859,13 +961,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"",
- req(
- CommonParams.Q,
- "AAAA",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elevated]"),
+ reqWithPath("/elevate", CommonParams.Q, "AAAA", CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='7']",
"//result/doc[2]/str[@name='id'][.='8']",
@@ -933,7 +1029,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"Make sure QEC handles null queries",
- req("qt", "/elevate", "q.alt", "*:*", "defType", "dismax"),
+ reqWithPath("/elevate", "q.alt", "*:*", "defType", "dismax"),
"//*[@numFound='0']");
}
} finally {
@@ -957,13 +1053,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"",
- req(
- CommonParams.Q,
- "XXXX",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elevated]"),
+ reqWithPath("/elevate", CommonParams.Q, "XXXX", CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='4']",
@@ -974,26 +1064,14 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"",
- req(
- CommonParams.Q,
- "AAAA",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elevated]"),
+ reqWithPath("/elevate", CommonParams.Q, "AAAA", CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='7']",
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
assertQ(
"",
- req(
- CommonParams.Q,
- "AAAA",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elev]"),
+ reqWithPath("/elevate", CommonParams.Q, "AAAA", CommonParams.FL,
"id, score, [elev]"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='7']",
"not(//result/doc[1]/bool[@name='[elevated]'][.='false'])",
@@ -1027,11 +1105,10 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"",
- req(
+ reqWithPath(
+ "/elevate",
CommonParams.Q,
"XXXX XXXX",
- CommonParams.QT,
- "/elevate",
QueryElevationParams.MARK_EXCLUDES,
"true",
"indent",
@@ -1052,11 +1129,10 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// thus, number 6 should not be returned, b/c it is excluded
assertQ(
"",
- req(
+ reqWithPath(
+ "/elevate",
CommonParams.Q,
"XXXX XXXX",
- CommonParams.QT,
- "/elevate",
QueryElevationParams.MARK_EXCLUDES,
"false",
CommonParams.FL,
@@ -1075,11 +1151,10 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// excluded results)
assertQ(
"",
- req(
+ reqWithPath(
+ "/elevate",
CommonParams.Q,
"QQQQ",
- CommonParams.QT,
- "/elevate",
QueryElevationParams.ENABLE,
"false",
"indent",
@@ -1092,11 +1167,10 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
"//result/doc[3]/str[@name='id'][.='8']");
assertQ(
"",
- req(
+ reqWithPath(
+ "/elevate",
CommonParams.Q,
"QQQQ",
- CommonParams.QT,
- "/elevate",
QueryElevationParams.MARK_EXCLUDES,
"true",
"indent",
@@ -1132,7 +1206,6 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
final SolrParams baseParams =
params(
- "qt", "/elevate",
"q", query,
"fl", "id,score",
"indent", "true");
@@ -1143,7 +1216,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"Make sure standard sort works as expected",
- req(baseParams),
+ reqWithPath("/elevate", baseParams),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='c']",
"//result/doc[2]/str[@name='id'][.='b']",
@@ -1154,7 +1227,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"All six should make it",
- req(baseParams),
+ reqWithPath("/elevate", baseParams),
"//*[@numFound='6']",
"//result/doc[1]/str[@name='id'][.='x']",
"//result/doc[2]/str[@name='id'][.='y']",
@@ -1166,7 +1239,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// now switch the order:
booster.setTopQueryResults(reader, query, false, new String[] {"a",
"x"}, null);
assertQ(
- req(baseParams),
+ reqWithPath("/elevate", baseParams),
"//*[@numFound='4']",
"//result/doc[1]/str[@name='id'][.='a']",
"//result/doc[2]/str[@name='id'][.='x']",
@@ -1177,7 +1250,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// default 'forceBoost' should be false
assertFalse(booster.forceElevation);
assertQ(
- req(baseParams, "sort", "id asc"),
+ reqWithPath("/elevate", baseParams, "sort", "id asc"),
"//*[@numFound='4']",
"//result/doc[1]/str[@name='id'][.='a']",
"//result/doc[2]/str[@name='id'][.='b']",
@@ -1186,7 +1259,13 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"useConfiguredElevatedOrder=false",
- req(baseParams, "sort", "str_s1 asc,id desc",
"useConfiguredElevatedOrder", "false"),
+ reqWithPath(
+ "/elevate",
+ baseParams,
+ "sort",
+ "str_s1 asc,id desc",
+ "useConfiguredElevatedOrder",
+ "false"),
"//*[@numFound='4']",
"//result/doc[1]/str[@name='id'][.='x']", // group1
"//result/doc[2]/str[@name='id'][.='a']", // group1
@@ -1195,7 +1274,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
booster.forceElevation = true;
assertQ(
- req(baseParams, "sort", "id asc"),
+ reqWithPath("/elevate", baseParams, "sort", "id asc"),
"//*[@numFound='4']",
"//result/doc[1]/str[@name='id'][.='a']",
"//result/doc[2]/str[@name='id'][.='x']",
@@ -1205,7 +1284,8 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
booster.forceElevation = true;
assertQ(
"useConfiguredElevatedOrder=false and forceElevation",
- req(baseParams, "sort", "id desc", "useConfiguredElevatedOrder",
"false"),
+ reqWithPath(
+ "/elevate", baseParams, "sort", "id desc",
"useConfiguredElevatedOrder", "false"),
"//*[@numFound='4']",
"//result/doc[1]/str[@name='id'][.='x']", // force elevated
"//result/doc[2]/str[@name='id'][.='a']", // force elevated
@@ -1215,7 +1295,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// Test exclusive (not to be confused with exclusion)
booster.setTopQueryResults(reader, query, false, new String[] {"x",
"a"}, new String[] {});
assertQ(
- req(baseParams, "exclusive", "true"),
+ reqWithPath("/elevate", baseParams, "exclusive", "true"),
"//*[@numFound='2']",
"//result/doc[1]/str[@name='id'][.='x']",
"//result/doc[2]/str[@name='id'][.='a']");
@@ -1223,7 +1303,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// Test exclusion
booster.setTopQueryResults(reader, query, false, new String[] {"x"}, new
String[] {"a"});
assertQ(
- req(baseParams),
+ reqWithPath("/elevate", baseParams),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='x']",
"//result/doc[2]/str[@name='id'][.='c']",
@@ -1234,7 +1314,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
booster.clearElevationProviderCache();
assertQ(
"All five should make it",
- req(baseParams, "elevateIds", "x,y,z", "excludeIds", "b"),
+ reqWithPath("/elevate", baseParams, "elevateIds", "x,y,z",
"excludeIds", "b"),
"//*[@numFound='5']",
"//result/doc[1]/str[@name='id'][.='x']",
"//result/doc[2]/str[@name='id'][.='y']",
@@ -1244,7 +1324,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"All four should make it",
- req(baseParams, "elevateIds", "x,z,y", "excludeIds", "b,c"),
+ reqWithPath("/elevate", baseParams, "elevateIds", "x,z,y",
"excludeIds", "b,c"),
"//*[@numFound='4']",
"//result/doc[1]/str[@name='id'][.='x']",
"//result/doc[2]/str[@name='id'][.='z']",
@@ -1363,23 +1443,16 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
assertQ(
"",
- req(
- CommonParams.Q,
- "AAAA",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elevated]"),
+ reqWithPath("/elevate", CommonParams.Q, "AAAA", CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='1']",
"//result/doc[1]/str[@name='id'][.='7']",
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
assertQ(
"",
- req(
+ reqWithPath(
+ "/elevate",
CommonParams.Q,
"{!q.op=AND}AAAA",
- CommonParams.QT,
- "/elevate",
CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='1']",
@@ -1387,11 +1460,10 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
"//result/doc[1]/bool[@name='[elevated]'][.='true']");
assertQ(
"",
- req(
+ reqWithPath(
+ "/elevate",
CommonParams.Q,
"{!q.op=AND v='AAAA'}",
- CommonParams.QT,
- "/elevate",
CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='1']",
@@ -1425,13 +1497,7 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// Exact matching.
assertQ(
"",
- req(
- CommonParams.Q,
- "XXXX",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elevated]"),
+ reqWithPath("/elevate", CommonParams.Q, "XXXX", CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='4']",
@@ -1443,25 +1509,15 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// Exact matching.
assertQ(
"",
- req(
- CommonParams.Q,
- "QQQQ EE",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate", CommonParams.Q, "QQQQ EE", CommonParams.FL, "id,
score, [elevated]"),
"//*[@numFound='0']");
// Subset matching.
assertQ(
"",
- req(
- CommonParams.Q,
- "BB DD CC VV",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate", CommonParams.Q, "BB DD CC VV", CommonParams.FL, "id,
score, [elevated]"),
"//*[@numFound='4']",
"//result/doc[1]/str[@name='id'][.='10']",
"//result/doc[2]/str[@name='id'][.='12']",
@@ -1475,13 +1531,8 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// Subset + exact matching.
assertQ(
"",
- req(
- CommonParams.Q,
- "BB CC",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate", CommonParams.Q, "BB CC", CommonParams.FL, "id,
score, [elevated]"),
"//*[@numFound='4']",
"//result/doc[1]/str[@name='id'][.='13']",
"//result/doc[2]/str[@name='id'][.='10']",
@@ -1495,11 +1546,10 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// Subset matching.
assertQ(
"",
- req(
+ reqWithPath(
+ "/elevate",
CommonParams.Q,
"AA BB DD CC AA",
- CommonParams.QT,
- "/elevate",
CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='4']",
@@ -1515,11 +1565,10 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// Subset matching.
assertQ(
"",
- req(
+ reqWithPath(
+ "/elevate",
CommonParams.Q,
"AA RR BB DD AA",
- CommonParams.QT,
- "/elevate",
CommonParams.FL,
"id, score, [elevated]"),
"//*[@numFound='3']",
@@ -1533,13 +1582,8 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// Subset matching.
assertQ(
"",
- req(
- CommonParams.Q,
- "AA BB EE",
- CommonParams.QT,
- "/elevate",
- CommonParams.FL,
- "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate", CommonParams.Q, "AA BB EE", CommonParams.FL, "id,
score, [elevated]"),
"//*[@numFound='0']");
} finally {
delete();
@@ -1598,11 +1642,14 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// default behaviour
assertQ(
"",
- req(
- CommonParams.Q, "YYYY",
- CommonParams.QT, "/elevate",
- QueryElevationParams.ELEVATE_ONLY_DOCS_MATCHING_QUERY, "false",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "YYYY",
+ QueryElevationParams.ELEVATE_ONLY_DOCS_MATCHING_QUERY,
+ "false",
+ CommonParams.FL,
+ "id, score, [elevated]"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='2']",
@@ -1614,11 +1661,14 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// only docs that matches q
assertQ(
"",
- req(
- CommonParams.Q, "YYYY",
- CommonParams.QT, "/elevate",
- QueryElevationParams.ELEVATE_ONLY_DOCS_MATCHING_QUERY, "true",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "YYYY",
+ QueryElevationParams.ELEVATE_ONLY_DOCS_MATCHING_QUERY,
+ "true",
+ CommonParams.FL,
+ "id, score, [elevated]"),
"//*[@numFound='2']",
"//result/doc[1]/str[@name='id'][.='2']",
"//result/doc[2]/str[@name='id'][.='5']",
@@ -1644,12 +1694,16 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// default behaviour - all elevated docs are visible
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CollapsingQParserPlugin.COLLECT_ELEVATED_DOCS_WHEN_COLLAPSING,
"true",
- CommonParams.FQ, "{!collapse field=str_s1 sort='score desc'}",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CollapsingQParserPlugin.COLLECT_ELEVATED_DOCS_WHEN_COLLAPSING,
+ "true",
+ CommonParams.FQ,
+ "{!collapse field=str_s1 sort='score desc'}",
+ CommonParams.FL,
+ "id, score, [elevated]"),
"//*[@numFound='4']",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='2']",
@@ -1663,12 +1717,16 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// only representative elevated doc visible
assertQ(
"",
- req(
- CommonParams.Q, "ZZZZ",
- CommonParams.QT, "/elevate",
- CollapsingQParserPlugin.COLLECT_ELEVATED_DOCS_WHEN_COLLAPSING,
"false",
- CommonParams.FQ, "{!collapse field=str_s1 sort='score desc'}",
- CommonParams.FL, "id, score, [elevated]"),
+ reqWithPath(
+ "/elevate",
+ CommonParams.Q,
+ "ZZZZ",
+ CollapsingQParserPlugin.COLLECT_ELEVATED_DOCS_WHEN_COLLAPSING,
+ "false",
+ CommonParams.FQ,
+ "{!collapse field=str_s1 sort='score desc'}",
+ CommonParams.FL,
+ "id, score, [elevated]"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='2']",
"//result/doc[2]/str[@name='id'][.='3']",
@@ -1698,7 +1756,6 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
final SolrParams baseParams =
params(
- "qt", "/elevate",
"q", "title:ipod",
"sort", "score desc, id asc",
"fl", "id",
@@ -1707,13 +1764,13 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
// sanity check everything returned w/these elevation options...
assertJQ(
- req(baseParams),
+ reqWithPath("/elevate", baseParams),
"/response/numFound==5",
"/response/start==0",
"/response/docs==[{'id':'x'},{'id':'y'},{'id':'z'},{'id':'c'},{'id':'a'}]");
// same query using CURSOR_MARK_START should produce a 'next' cursor...
assertCursorJQ(
- req(baseParams, CURSOR_MARK_PARAM, CURSOR_MARK_START),
+ reqWithPath("/elevate", baseParams, CURSOR_MARK_PARAM,
CURSOR_MARK_START),
"/response/numFound==5",
"/response/start==0",
"/response/docs==[{'id':'x'},{'id':'y'},{'id':'z'},{'id':'c'},{'id':'a'}]");
@@ -1722,26 +1779,27 @@ public class QueryElevationComponentTest extends
SolrTestCaseJ4 {
String nextCursor = null;
nextCursor =
assertCursorJQ(
- req(baseParams, CURSOR_MARK_PARAM, CURSOR_MARK_START, "rows",
"2"),
+ reqWithPath(
+ "/elevate", baseParams, CURSOR_MARK_PARAM,
CURSOR_MARK_START, "rows", "2"),
"/response/numFound==5",
"/response/start==0",
"/response/docs==[{'id':'x'},{'id':'y'}]");
nextCursor =
assertCursorJQ(
- req(baseParams, CURSOR_MARK_PARAM, nextCursor, "rows", "2"),
+ reqWithPath("/elevate", baseParams, CURSOR_MARK_PARAM,
nextCursor, "rows", "2"),
"/response/numFound==5",
"/response/start==0",
"/response/docs==[{'id':'z'},{'id':'c'}]");
nextCursor =
assertCursorJQ(
- req(baseParams, CURSOR_MARK_PARAM, nextCursor, "rows", "2"),
+ reqWithPath("/elevate", baseParams, CURSOR_MARK_PARAM,
nextCursor, "rows", "2"),
"/response/numFound==5",
"/response/start==0",
"/response/docs==[{'id':'a'}]");
final String lastCursor = nextCursor;
nextCursor =
assertCursorJQ(
- req(baseParams, CURSOR_MARK_PARAM, nextCursor, "rows", "2"),
+ reqWithPath("/elevate", baseParams, CURSOR_MARK_PARAM,
nextCursor, "rows", "2"),
"/response/numFound==5",
"/response/start==0",
"/response/docs==[]");
diff --git
a/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
b/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
index 670a4d8aef2..32470b57ce2 100644
---
a/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
+++
b/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
@@ -227,11 +227,10 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
private void doBasics() throws Exception {
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
TermVectorComponent.COMPONENT_NAME,
@@ -246,11 +245,10 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
+ " 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}}");
// tv.fl diff from fl
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
"fl",
@@ -266,11 +264,10 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
+ " 'test_offtv':{'anoth':{'tf':1},'titl':{'tf':2}}}}");
// multi-valued tv.fl
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
"fl",
@@ -288,11 +285,10 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
+ " 'test_offtv':{'anoth':{'tf':1},'titl':{'tf':2}}}}");
// re-use fl glob
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
"fl",
@@ -309,11 +305,10 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
+ " 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}}");
// re-use fl, ignore things we can't handle
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
"fl",
@@ -327,11 +322,10 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
+ " 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}}");
// re-use (multi-valued) fl, ignore things we can't handle
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
"fl",
@@ -349,11 +343,10 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
private void doOptions() throws Exception {
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
TermVectorComponent.COMPONENT_NAME,
@@ -371,11 +364,10 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
"/termVectors/0/test_posofftv/anoth=={'tf':1, 'offsets':{'start':20,
'end':27}, 'positions':{'position':5}, 'df':2, 'tf-idf':0.5}");
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
TermVectorComponent.COMPONENT_NAME,
@@ -387,8 +379,7 @@ public class TermVectorComponentTest extends SolrTestCaseJ4
{
// test each combination at random
final List<String> list = new ArrayList<>();
list.addAll(
- Arrays.asList(
- "json.nl", "map", "qt", tv, "q", "id:0",
TermVectorComponent.COMPONENT_NAME, "true"));
+ Arrays.asList("json.nl", "map", "q", "id:0",
TermVectorComponent.COMPONENT_NAME, "true"));
String[][] options =
new String[][] {
{TermVectorParams.TF, "'tf':1"},
@@ -413,16 +404,15 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
}
expected.append("}");
- assertJQ(req(list.toArray(new String[0])), expected.toString());
+ assertJQ(reqWithPath(tv, list.toArray(new String[0])),
expected.toString());
}
private void doPerField() throws Exception {
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
TermVectorComponent.COMPONENT_NAME,
@@ -462,11 +452,10 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
// stuffs start (20) and end offset (27) into the
// payload:
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
TermVectorComponent.COMPONENT_NAME,
@@ -498,11 +487,10 @@ public class TermVectorComponentTest extends
SolrTestCaseJ4 {
// Kind of an odd test, but we just want to know if we don't generate an
NPE when there is
// nothing to give back in the term vectors.
assertJQ(
- req(
+ reqWithPath(
+ tv,
"json.nl",
"map",
- "qt",
- tv,
"q",
"id:0",
TermVectorComponent.COMPONENT_NAME,
diff --git
a/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
b/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
index 2870fb222bb..d939c5b3764 100644
---
a/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
+++
b/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
@@ -84,7 +84,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testEmptyLower() {
assertQ(
- req("indent", "true", "qt", "/terms", "terms.fl", "lowerfilt",
"terms.upper", "b"),
+ reqWithPath("/terms", "indent", "true", "terms.fl", "lowerfilt",
"terms.upper", "b"),
"count(//lst[@name='lowerfilt']/*)=6",
"//int[@name='a'] ",
"//int[@name='aa'] ",
@@ -97,11 +97,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testMultipleFields() {
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"lowerfilt",
"terms.upper",
@@ -115,15 +114,15 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testUnlimitedRows() {
assertQ(
- req("indent", "true", "qt", "/terms", "terms.fl", "lowerfilt",
"terms.fl", "standardfilt"),
+ reqWithPath(
+ "/terms", "indent", "true", "terms.fl", "lowerfilt", "terms.fl",
"standardfilt"),
"count(//lst[@name='lowerfilt']/*)=9",
"count(//lst[@name='standardfilt']/*)=10");
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"lowerfilt",
"terms.fl",
@@ -137,11 +136,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testPrefix() {
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"lowerfilt",
"terms.upper",
@@ -165,11 +163,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testRegexp() {
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"standardfilt",
"terms.lower",
@@ -219,11 +216,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
public void testRegexpWithFlags() {
// TODO: there are no uppercase or mixed-case terms in the index!
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"standardfilt",
"terms.lower",
@@ -244,11 +240,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testSortCount() {
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"standardfilt",
"terms.lower",
@@ -269,11 +264,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
public void testTermsList() {
// Terms list always returns in index order
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"standardfilt",
"terms.list",
@@ -287,7 +281,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
// Test with numeric terms
assertQ(
- req("indent", "true", "qt", "/terms", "terms.fl", "foo_i",
"terms.list", "2,1"),
+ reqWithPath("/terms", "indent", "true", "terms.fl", "foo_i",
"terms.list", "2,1"),
"count(//lst[@name='foo_i']/*)=2",
"//lst[@name='foo_i']/int[1][@name='1'][.='2']",
"//lst[@name='foo_i']/int[2][@name='2'][.='1']");
@@ -297,11 +291,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
public void testStats() {
// Terms list always returns in index order
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"standardfilt",
"terms.stats",
@@ -314,11 +307,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testSortIndex() {
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"standardfilt",
"terms.lower",
@@ -338,11 +330,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testPastUpper() {
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"lowerfilt",
// no upper bound, lower bound doesn't exist
@@ -354,11 +345,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testLowerExclusive() {
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"lowerfilt",
"terms.lower",
@@ -375,11 +365,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
"//int[@name='abc'] ");
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"standardfilt",
"terms.lower",
@@ -394,11 +383,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void test() {
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"lowerfilt",
"terms.lower",
@@ -414,11 +402,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
"//int[@name='abc'] ");
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"lowerfilt",
"terms.lower",
@@ -426,36 +413,36 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
"terms.upper",
"b",
"terms.raw",
- "true", // this should have no effect on a text field
+ "true",
+ // this should have no effect on a text field
"terms.limit",
"2"),
"count(//lst[@name='lowerfilt']/*)=2",
"//int[@name='a']",
"//int[@name='aa']");
- assertQ(req("indent", "true", "qt", "/terms", "terms.fl", "foo_i"),
"//int[@name='1'][.='2']");
+ assertQ(
+ reqWithPath("/terms", "indent", "true", "terms.fl", "foo_i"),
"//int[@name='1'][.='2']");
/* terms.raw only applies to indexed fields
assertQ(req("indent","true", "qt","/terms",
"terms.fl","foo_i", "terms.raw","true")
- ,"not(//int[@name='1'][.='2'])"
- );
+ ,"not(//int[@name='1'][.='2'])");
*/
// check something at the end of the index
assertQ(
- req("indent", "true", "qt", "/terms", "terms.fl", "zzz_i"),
+ reqWithPath("/terms", "indent", "true", "terms.fl", "zzz_i"),
"count(//lst[@name='zzz_i']/*)=0");
}
@Test
public void testMinMaxFreq() {
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"lowerfilt",
"terms.lower",
@@ -469,11 +456,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
"count(//lst[@name='lowerfilt']/*)=1");
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"standardfilt",
"terms.lower",
@@ -490,24 +476,15 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testTermsWithJSON() throws Exception {
ModifiableSolrParams params =
- params(
- "qt",
- "/terms",
- "terms.fl",
- "standardfilt",
- "terms.lower",
- "a",
- "terms.sort",
- "index",
- "wt",
- "json");
+ params("terms.fl", "standardfilt", "terms.lower", "a", "terms.sort",
"index", "wt", "json");
- assertJQ(req(params), "/terms/standardfilt/[0]==a",
"/terms/standardfilt/[1]==1");
+ assertJQ(
+ reqWithPath("/terms", params), "/terms/standardfilt/[0]==a",
"/terms/standardfilt/[1]==1");
// enable terms.ttf
params.set("terms.ttf", "true");
assertJQ(
- req(params),
+ reqWithPath("/terms", params),
"/terms/standardfilt/[0]==a",
"/terms/standardfilt/[1]/df==1",
"/terms/standardfilt/[1]/ttf==1");
@@ -516,7 +493,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
params.set("terms.list", "spider,snake,shark");
params.remove("terms.ttf");
assertJQ(
- req(params),
+ reqWithPath("/terms", params),
"/terms/standardfilt/[0]==shark",
"/terms/standardfilt/[1]==2",
"/terms/standardfilt/[2]==snake",
@@ -526,7 +503,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
// with terms.list and terms.ttf=true
params.set("terms.ttf", "true");
assertJQ(
- req(params),
+ reqWithPath("/terms", params),
"/terms/standardfilt/[0]==shark",
"/terms/standardfilt/[1]/df==2",
"/terms/standardfilt/[1]/ttf==2",
@@ -541,12 +518,16 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testDocFreqAndTotalTermFreq() {
SolrQueryRequest req =
- req(
- "indent", "true",
- "qt", "/terms",
- "terms.fl", "standardfilt",
- "terms.ttf", "true",
- "terms.list", "snake,spider,shark,ddddd");
+ reqWithPath(
+ "/terms",
+ "indent",
+ "true",
+ "terms.fl",
+ "standardfilt",
+ "terms.ttf",
+ "true",
+ "terms.list",
+ "snake,spider,shark,ddddd");
assertQ(
req,
"count(//lst[@name='standardfilt']/*)=4",
@@ -561,13 +542,18 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
// terms.limit=-1 and terms.sort=count and NO terms.list
req =
- req(
- "indent", "true",
- "qt", "/terms",
- "terms.fl", "standardfilt",
- "terms.ttf", "true",
- "terms.limit", "-1",
- "terms.sort", "count");
+ reqWithPath(
+ "/terms",
+ "indent",
+ "true",
+ "terms.fl",
+ "standardfilt",
+ "terms.ttf",
+ "true",
+ "terms.limit",
+ "-1",
+ "terms.sort",
+ "count");
assertQ(
req,
"count(//lst[@name='standardfilt']/*)>=4", // it would be at-least 4
@@ -584,12 +570,16 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testDocFreqAndTotalTermFreqForNonExistingTerm() {
SolrQueryRequest req =
- req(
- "indent", "true",
- "qt", "/terms",
- "terms.fl", "standardfilt",
- "terms.ttf", "true",
- "terms.list", "boo,snake");
+ reqWithPath(
+ "/terms",
+ "indent",
+ "true",
+ "terms.fl",
+ "standardfilt",
+ "terms.ttf",
+ "true",
+ "terms.list",
+ "boo,snake");
assertQ(
req,
"count(//lst[@name='standardfilt']/*)=1",
@@ -600,13 +590,18 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
@Test
public void testDocFreqAndTotalTermFreqForMultipleFields() {
SolrQueryRequest req =
- req(
- "indent", "true",
- "qt", "/terms",
- "terms.fl", "lowerfilt",
- "terms.fl", "standardfilt",
- "terms.ttf", "true",
- "terms.list", "a,aa,aaa");
+ reqWithPath(
+ "/terms",
+ "indent",
+ "true",
+ "terms.fl",
+ "lowerfilt",
+ "terms.fl",
+ "standardfilt",
+ "terms.ttf",
+ "true",
+ "terms.list",
+ "a,aa,aaa");
assertQ(
req,
"count(//lst[@name='lowerfilt']/*)=3",
@@ -626,14 +621,20 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
// terms.ttf=true, terms.sort=index and no terms list
req =
- req(
- "indent", "true",
- "qt", "/terms",
- "terms.fl", "lowerfilt",
- "terms.fl", "standardfilt",
- "terms.ttf", "true",
- "terms.sort", "index",
- "terms.limit", "10");
+ reqWithPath(
+ "/terms",
+ "indent",
+ "true",
+ "terms.fl",
+ "lowerfilt",
+ "terms.fl",
+ "standardfilt",
+ "terms.ttf",
+ "true",
+ "terms.sort",
+ "index",
+ "terms.limit",
+ "10");
assertQ(
req,
"count(//lst[@name='lowerfilt']/*)<=10",
@@ -689,10 +690,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
val2 = vals[i];
}
- SolrQueryRequest req =
- req(
- "qt", "/terms",
- "terms.fl", "foo_pi");
+ SolrQueryRequest req = req("terms.fl", "foo_pi");
;
try {
/* SchemaField sf = req.getSchema().getField("foo_pi");
@@ -777,11 +775,10 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
assertEquals(i, nvals);
assertQ(
- req(
+ reqWithPath(
+ "/terms",
"indent",
"true",
- "qt",
- "/terms",
"terms.fl",
"foo_pi",
"terms.sort",
@@ -834,7 +831,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
assertU(commit());
assertQ(
- req("indent", "true", "qt", "/terms", "terms.fl", "foo_pdt",
"terms.sort", "count"),
+ reqWithPath("/terms", "indent", "true", "terms.fl", "foo_pdt",
"terms.sort", "count"),
"count(//lst[@name='foo_pdt']/*)=2",
"//lst[@name='foo_pdt']/int[1][@name='" + dates[1] + "'][.='51']",
"//lst[@name='foo_pdt']/int[2][@name='" + dates[0] + "'][.='50']");
@@ -844,7 +841,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
assertU(commit());
assertQ(
- req("indent", "true", "qt", "/terms", "terms.fl", "foo_pdt",
"terms.sort", "count"),
+ reqWithPath("/terms", "indent", "true", "terms.fl", "foo_pdt",
"terms.sort", "count"),
"count(//lst[@name='foo_pdt']/*)=0");
}
}
diff --git
a/solr/core/src/test/org/apache/solr/handler/component/TestMatchedQueriesComponent.java
b/solr/core/src/test/org/apache/solr/handler/component/TestMatchedQueriesComponent.java
index a0a4b891742..c6954400fc2 100644
---
a/solr/core/src/test/org/apache/solr/handler/component/TestMatchedQueriesComponent.java
+++
b/solr/core/src/test/org/apache/solr/handler/component/TestMatchedQueriesComponent.java
@@ -47,7 +47,7 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testNotEnabledByDefault() throws Exception {
assertJQ(
- req("qt", HANDLER, "q", "{!term name=fantasy_cat f=cat_s}fantasy",
"sort", "id asc"),
+ reqWithPath(HANDLER, "q", "{!term name=fantasy_cat f=cat_s}fantasy",
"sort", "id asc"),
"!/matched_queries_per_hit==null",
"!/matched_queries_summary==null");
}
@@ -56,12 +56,16 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testSingleNamedTermQuery() throws Exception {
assertJQ(
- req(
- "qt", HANDLER,
- "q", "{!term name=fantasy_cat f=cat_s}fantasy",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ reqWithPath(
+ HANDLER,
+ "q",
+ "{!term name=fantasy_cat f=cat_s}fantasy",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==4",
"/matched_queries_per_hit/1/[0]=='fantasy_cat'",
"/matched_queries_per_hit/2/[0]=='fantasy_cat'",
@@ -75,12 +79,16 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testShortParamAlias() throws Exception {
assertJQ(
- req(
- "qt", HANDLER,
- "q", "{!term name=fantasy_cat f=cat_s}fantasy",
- "mq", "true",
- "sort", "id asc",
- "rows", "10"),
+ reqWithPath(
+ HANDLER,
+ "q",
+ "{!term name=fantasy_cat f=cat_s}fantasy",
+ "mq",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==4",
"/matched_queries_summary/fantasy_cat/[0]=='1'");
}
@@ -92,13 +100,16 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testTwoNamedQueriesOr() throws Exception {
assertJQ(
- req(
- "qt", HANDLER,
+ reqWithPath(
+ HANDLER,
"q",
- "({!term name=fantasy_cat f=cat_s}fantasy) OR ({!term
name=scifi_cat f=cat_s}scifi)",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ "({!term name=fantasy_cat f=cat_s}fantasy) OR ({!term
name=scifi_cat f=cat_s}scifi)",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==7",
"/matched_queries_per_hit/1/[0]=='fantasy_cat'",
"/matched_queries_per_hit/5/[0]=='scifi_cat'",
@@ -110,12 +121,16 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testUnnamedQueryProducesNoOutput() throws Exception {
assertJQ(
- req(
- "qt", HANDLER,
- "q", "{!term f=cat_s}fantasy",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ reqWithPath(
+ HANDLER,
+ "q",
+ "{!term f=cat_s}fantasy",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==4",
"!/matched_queries_per_hit==null",
"!/matched_queries_summary==null");
@@ -126,13 +141,16 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
public void testMultiValuedFieldBothNamesPresent() throws Exception {
// docs 2 and 3 match both fantasy_cat and childrens_cat
assertJQ(
- req(
- "qt", HANDLER,
+ reqWithPath(
+ HANDLER,
"q",
- "({!term name=fantasy_cat f=cat_s}fantasy) OR ({!term
name=childrens_cat f=cat_s}childrens)",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ "({!term name=fantasy_cat f=cat_s}fantasy) OR ({!term
name=childrens_cat f=cat_s}childrens)",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==4",
"/matched_queries_summary/fantasy_cat/[3]=='4'",
"/matched_queries_summary/childrens_cat/[0]=='2'",
@@ -146,12 +164,16 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testTermsNamedQuery() throws Exception {
assertJQ(
- req(
- "qt", HANDLER,
- "q", "{!terms name=genre_all f=cat_s}fantasy,scifi",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ reqWithPath(
+ HANDLER,
+ "q",
+ "{!terms name=genre_all f=cat_s}fantasy,scifi",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==7",
"/matched_queries_per_hit/1/[0]=='genre_all'",
"/matched_queries_per_hit/5/[0]=='genre_all'",
@@ -167,15 +189,18 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testBoolOuterAndInnerNamesComposed() throws Exception {
assertJQ(
- req(
- "qt", HANDLER,
+ reqWithPath(
+ HANDLER,
"q",
- "{!bool name=all_books"
- + " should='{!term name=fantasy_cat f=cat_s}fantasy'"
- + " should='{!term name=scifi_cat f=cat_s}scifi'}",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ "{!bool name=all_books"
+ + " should='{!term name=fantasy_cat f=cat_s}fantasy'"
+ + " should='{!term name=scifi_cat f=cat_s}scifi'}",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==7",
// every doc carries all_books (outer name)
"/matched_queries_summary/all_books/[6]=='7'",
@@ -198,14 +223,17 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testBoolMultipleShouldNamedTerms() throws Exception {
assertJQ(
- req(
- "qt", HANDLER,
+ reqWithPath(
+ HANDLER,
"q",
- "{!bool should='{!term name=fantasy_cat f=cat_s}fantasy'"
- + " should='{!term name=scifi_cat f=cat_s}scifi'}",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ "{!bool should='{!term name=fantasy_cat f=cat_s}fantasy'"
+ + " should='{!term name=scifi_cat f=cat_s}scifi'}",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==7",
"/matched_queries_per_hit/1/[0]=='fantasy_cat'",
"/matched_queries_per_hit/4/[0]=='fantasy_cat'",
@@ -225,14 +253,17 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
public void testBoolMustWithNamedShould() throws Exception {
// MUST: all 4 fantasy docs; named SHOULD: only docs 2 and 3 (childrens)
assertJQ(
- req(
- "qt", HANDLER,
+ reqWithPath(
+ HANDLER,
"q",
- "{!bool must='{!term f=cat_s}fantasy'"
- + " should='{!term name=childrens_cat
f=cat_s}childrens'}",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ "{!bool must='{!term f=cat_s}fantasy'"
+ + " should='{!term name=childrens_cat f=cat_s}childrens'}",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==4",
// docs 2 and 3 matched the named SHOULD
"/matched_queries_per_hit/2/[0]=='childrens_cat'",
@@ -251,12 +282,16 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testPrefixNamedQuery() throws Exception {
assertJQ(
- req(
- "qt", HANDLER,
- "q", "{!prefix name=fanta_prefix f=cat_s}fanta",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ reqWithPath(
+ HANDLER,
+ "q",
+ "{!prefix name=fanta_prefix f=cat_s}fanta",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==4",
"/matched_queries_summary/fanta_prefix/[3]=='4'",
"/matched_queries_per_hit/1/[0]=='fanta_prefix'",
@@ -269,12 +304,16 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testEdismaxNamedQuery() throws Exception {
assertJQ(
- req(
- "qt", HANDLER,
- "q", "{!edismax name=fantasy_edismax qf=cat_s}fantasy",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ reqWithPath(
+ HANDLER,
+ "q",
+ "{!edismax name=fantasy_edismax qf=cat_s}fantasy",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==4",
"/matched_queries_summary/fantasy_edismax/[3]=='4'",
"/matched_queries_per_hit/1/[0]=='fantasy_edismax'",
@@ -287,12 +326,16 @@ public class TestMatchedQueriesComponent extends
SolrTestCaseJ4 {
@Test
public void testLuceneNamedQuery() throws Exception {
assertJQ(
- req(
- "qt", HANDLER,
- "q", "{!lucene name=scifi_lucene df=cat_s}scifi",
- "matched_queries", "true",
- "sort", "id asc",
- "rows", "10"),
+ reqWithPath(
+ HANDLER,
+ "q",
+ "{!lucene name=scifi_lucene df=cat_s}scifi",
+ "matched_queries",
+ "true",
+ "sort",
+ "id asc",
+ "rows",
+ "10"),
"/response/numFound==3",
"/matched_queries_summary/scifi_lucene/[2]=='7'",
"/matched_queries_per_hit/5/[0]=='scifi_lucene'",
diff --git a/solr/core/src/test/org/apache/solr/search/TestBlockCollapse.java
b/solr/core/src/test/org/apache/solr/search/TestBlockCollapse.java
index c6175d24dd7..92a5d523b7e 100644
--- a/solr/core/src/test/org/apache/solr/search/TestBlockCollapse.java
+++ b/solr/core/src/test/org/apache/solr/search/TestBlockCollapse.java
@@ -62,7 +62,7 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
Arrays.asList(
params(),
// QEC boosting shouldn't impact what impl we get in any situation
- params("qt", "/elevate", "elevateIds", "42"))) {
+ params("elevateIds", "42"))) {
try (SolrQueryRequest req = req()) {
// non-block based collapse situations, regardless of nullPolicy...
@@ -347,12 +347,16 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
// same query, but boosting a diff p1 sku to change group head
(and result order)
assertQ(
- req(
- "q", q,
- "qt", "/elevate",
- "elevateIds", "p1s1",
- "fq", "{!collapse " + opt + nullPolicy + "}",
- "sort", "score desc, num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ q,
+ "elevateIds",
+ "p1s1",
+ "fq",
+ "{!collapse " + opt + nullPolicy + "}",
+ "sort",
+ "score desc, num_i asc"),
"*[count(//doc)=3]",
"//result/doc[1]/str[@name='id'][.='p1s1']",
"//result/doc[2]/str[@name='id'][.='p2s4']",
@@ -360,12 +364,16 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
// same query, but boosting multiple skus from p1
assertQ(
- req(
- "q", q,
- "qt", "/elevate",
- "elevateIds", "p1s1,p1s2",
- "fq", "{!collapse " + opt + nullPolicy + "}",
- "sort", "score desc, num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ q,
+ "elevateIds",
+ "p1s1,p1s2",
+ "fq",
+ "{!collapse " + opt + nullPolicy + "}",
+ "sort",
+ "score desc, num_i asc"),
"*[count(//doc)=4]",
"//result/doc[1]/str[@name='id'][.='p1s1']",
"//result/doc[2]/str[@name='id'][.='p1s2']",
@@ -386,26 +394,36 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
"//result/doc[3][str[@name='id'][.='p2s3'] and
float[@name='score'][.=141.0]]");
// same query, but boosting a diff child to change group head (and
result order)
assertQ(
- req(
- "q", "{!func}sum(42, num_i)",
- "qt", "/elevate",
- "elevateIds", "p1s1",
- "fq", "{!collapse " + opt + nullPolicy + "}",
- "fl", "score,id",
- "sort", "score desc, num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "{!func}sum(42, num_i)",
+ "elevateIds",
+ "p1s1",
+ "fq",
+ "{!collapse " + opt + nullPolicy + "}",
+ "fl",
+ "score,id",
+ "sort",
+ "score desc, num_i asc"),
"*[count(//doc)=3]",
"//result/doc[1][str[@name='id'][.='p1s1'] and
float[@name='score'][.=84.0]]",
"//result/doc[2][str[@name='id'][.='p3s3'] and
float[@name='score'][.=1276.0]]",
"//result/doc[3][str[@name='id'][.='p2s3'] and
float[@name='score'][.=141.0]]");
// same query, but boosting multiple skus from p1
assertQ(
- req(
- "q", "{!func}sum(42, num_i)",
- "qt", "/elevate",
- "elevateIds", "p1s2,p1s1",
- "fq", "{!collapse " + opt + nullPolicy + "}",
- "fl", "score,id",
- "sort", "score desc, num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "{!func}sum(42, num_i)",
+ "elevateIds",
+ "p1s2,p1s1",
+ "fq",
+ "{!collapse " + opt + nullPolicy + "}",
+ "fl",
+ "score,id",
+ "sort",
+ "score desc, num_i asc"),
"*[count(//doc)=4]",
"//result/doc[1][str[@name='id'][.='p1s2'] and
float[@name='score'][.=52.0]]",
"//result/doc[2][str[@name='id'][.='p1s1'] and
float[@name='score'][.=84.0]]",
@@ -467,24 +485,32 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
"//result/doc[3]/str[@name='id'][.='p2s2']");
// same query, but boosting skus to change group head (and result
order)
assertQ(
- req(
- "q", "txt_t:* txt_t:XX",
- "qt", "/elevate",
- "elevateIds", "p2s3,p1s1",
- "fq", "{!collapse " + opt + selector + nullPolicy + "}",
- "sort", "score desc, num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "txt_t:* txt_t:XX",
+ "elevateIds",
+ "p2s3,p1s1",
+ "fq",
+ "{!collapse " + opt + selector + nullPolicy + "}",
+ "sort",
+ "score desc, num_i asc"),
"*[count(//doc)=3]",
"//result/doc[1]/str[@name='id'][.='p2s3']",
"//result/doc[2]/str[@name='id'][.='p1s1']",
"//result/doc[3]/str[@name='id'][.='p3s4']");
// same query, but boosting multiple skus from p1
assertQ(
- req(
- "q", "txt_t:* txt_t:XX",
- "qt", "/elevate",
- "elevateIds", "p2s3,p1s4,p1s3",
- "fq", "{!collapse " + opt + selector + nullPolicy + "}",
- "sort", "score desc, num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "txt_t:* txt_t:XX",
+ "elevateIds",
+ "p2s3,p1s4,p1s3",
+ "fq",
+ "{!collapse " + opt + selector + nullPolicy + "}",
+ "sort",
+ "score desc, num_i asc"),
"*[count(//doc)=4]",
"//result/doc[1]/str[@name='id'][.='p2s3']",
"//result/doc[2]/str[@name='id'][.='p1s4']",
@@ -525,13 +551,18 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
"//result/doc[3][str[@name='id'][.='p3s3'] and
float[@name='score'][.=1276.0]]");
// same query, but boosting multiple skus from p1
assertQ(
- req(
- "q", "{!func}sum(42, num_i)",
- "qt", "/elevate",
- "elevateIds", "p1s2,p1s1",
- "fq", "{!collapse " + opt + selector + nullPolicy + "}",
- "fl", "score,id",
- "sort", "num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "{!func}sum(42, num_i)",
+ "elevateIds",
+ "p1s2,p1s1",
+ "fq",
+ "{!collapse " + opt + selector + nullPolicy + "}",
+ "fl",
+ "score,id",
+ "sort",
+ "num_i asc"),
"*[count(//doc)=4]",
"//result/doc[1][str[@name='id'][.='p1s2'] and
float[@name='score'][.=52.0]]",
"//result/doc[2][str[@name='id'][.='p1s1'] and
float[@name='score'][.=84.0]]",
@@ -565,13 +596,18 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
// NOTE: this causes each boosted doc to be returned, but top
level sort is not score,
// so QEC doesn't hijack order
assertQ(
- req(
- "q", "*:* txt_t:XX",
- "qt", "/elevate",
- "elevateIds", "p3s3,p3s2",
- "fq", "{!collapse " + opt + selector + nullPolicy + "}",
- "fl", "id",
- "sort", "num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "*:* txt_t:XX",
+ "elevateIds",
+ "p3s3,p3s2",
+ "fq",
+ "{!collapse " + opt + selector + nullPolicy + "}",
+ "fl",
+ "id",
+ "sort",
+ "num_i asc"),
"*[count(//doc)=4]",
"//result/doc[1][str[@name='id'][.='p2s4']]", // 13
// 100 (boosted so treated as own group)
@@ -581,14 +617,20 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
"//result/doc[4][str[@name='id'][.='p3s3']]");
// same query, w/forceElevation to change top level order
assertQ(
- req(
- "q", "*:* txt_t:XX",
- "qt", "/elevate",
- "elevateIds", "p3s3,p3s2",
- "forceElevation", "true",
- "fq", "{!collapse " + opt + selector + nullPolicy + "}",
- "fl", "id",
- "sort", "num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "*:* txt_t:XX",
+ "elevateIds",
+ "p3s3,p3s2",
+ "forceElevation",
+ "true",
+ "fq",
+ "{!collapse " + opt + selector + nullPolicy + "}",
+ "fl",
+ "id",
+ "sort",
+ "num_i asc"),
"*[count(//doc)=4]",
// 1234 (boosted so treated as own group)
"//result/doc[1][str[@name='id'][.='p3s3']]",
@@ -654,12 +696,16 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
"//result/doc[7]/str[@name='id'][.='z100']");
// same query, but boosting docs to change group heads (and result
order)
assertQ(
- req(
- "q", "*:* txt_t:XX",
- "qt", "/elevate",
- "elevateIds", "z2,p3s3",
- "fq", "{!collapse " + opt + " nullPolicy=expand}",
- "sort", "score desc, num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "*:* txt_t:XX",
+ "elevateIds",
+ "z2,p3s3",
+ "fq",
+ "{!collapse " + opt + " nullPolicy=expand}",
+ "sort",
+ "score desc, num_i asc"),
"*[count(//doc)=7]",
"//result/doc[1]/str[@name='id'][.='z2']",
"//result/doc[2]/str[@name='id'][.='p3s3']",
@@ -686,13 +732,18 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
"//result/doc[7][str[@name='id'][.='z1'] and
float[@name='score'][.=43.0]]");
// same query, but boosting docs to change group heads (and result
order)
assertQ(
- req(
- "q", "{!func}sum(42, num_i)",
- "qt", "/elevate",
- "elevateIds", "p2s4,z2,p2s1",
- "fq", "{!collapse " + opt + " nullPolicy=expand}",
- "fl", "score,id",
- "sort", "score desc, num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "{!func}sum(42, num_i)",
+ "elevateIds",
+ "p2s4,z2,p2s1",
+ "fq",
+ "{!collapse " + opt + " nullPolicy=expand}",
+ "fl",
+ "score,id",
+ "sort",
+ "score desc, num_i asc"),
"*[count(//doc)=8]",
"//result/doc[1][str[@name='id'][.='p2s4'] and
float[@name='score'][.=55.0]]",
"//result/doc[2][str[@name='id'][.='z2'] and
float[@name='score'][.=44.0]]",
@@ -758,12 +809,16 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
// NOTE: this causes each boosted doc to be returned, but top level
sort is not score, so
// QEC doesn't hijack order
assertQ(
- req(
- "q", "num_i:* txt_t:XX",
- "qt", "/elevate",
- "elevateIds", "p3s3,z3,p3s1",
- "fq", "{!collapse " + opt + selector + " nullPolicy=expand}",
- "sort", "num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "num_i:* txt_t:XX",
+ "elevateIds",
+ "p3s3,z3,p3s1",
+ "fq",
+ "{!collapse " + opt + selector + " nullPolicy=expand}",
+ "sort",
+ "num_i asc"),
"*[count(//doc)=8]",
"//result/doc[1]/str[@name='id'][.='z1']",
"//result/doc[2]/str[@name='id'][.='z2']",
@@ -775,13 +830,18 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
"//result/doc[8]/str[@name='id'][.='p3s3']");
// same query, w/forceElevation to change top level order
assertQ(
- req(
- "q", "num_i:* txt_t:XX",
- "qt", "/elevate",
- "elevateIds", "p3s3,z3,p3s1",
- "forceElevation", "true",
- "fq", "{!collapse " + opt + selector + " nullPolicy=expand}",
- "sort", "num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "num_i:* txt_t:XX",
+ "elevateIds",
+ "p3s3,z3,p3s1",
+ "forceElevation",
+ "true",
+ "fq",
+ "{!collapse " + opt + selector + " nullPolicy=expand}",
+ "sort",
+ "num_i asc"),
"*[count(//doc)=8]",
"//result/doc[1]/str[@name='id'][.='p3s3']",
"//result/doc[2]/str[@name='id'][.='z3']",
@@ -832,13 +892,18 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
// NOTE: this causes each boosted doc to be returned, but top level
sort is not score, so
// QEC doesn't hijack order
assertQ(
- req(
- "q", "{!func}sum(42, num_i)",
- "qt", "/elevate",
- "elevateIds", "p3s1,z3,p3s4",
- "fq", "{!collapse " + opt + selector + " nullPolicy=expand}",
- "fl", "score,id",
- "sort", "num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "{!func}sum(42, num_i)",
+ "elevateIds",
+ "p3s1,z3,p3s4",
+ "fq",
+ "{!collapse " + opt + selector + " nullPolicy=expand}",
+ "fl",
+ "score,id",
+ "sort",
+ "num_i asc"),
"*[count(//doc)=8]",
"//result/doc[1][str[@name='id'][.='z1'] and
float[@name='score'][.=43.0]]",
"//result/doc[2][str[@name='id'][.='z2'] and
float[@name='score'][.=44.0]]",
@@ -850,14 +915,20 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
"//result/doc[8][str[@name='id'][.='p1s3'] and
float[@name='score'][.=819.0]]");
// same query, w/forceElevation to change top level order
assertQ(
- req(
- "q", "{!func}sum(42, num_i)",
- "qt", "/elevate",
- "elevateIds", "p3s1,z3,p3s4",
- "forceElevation", "true",
- "fq", "{!collapse " + opt + selector + " nullPolicy=expand}",
- "fl", "score,id",
- "sort", "num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "{!func}sum(42, num_i)",
+ "elevateIds",
+ "p3s1,z3,p3s4",
+ "forceElevation",
+ "true",
+ "fq",
+ "{!collapse " + opt + selector + " nullPolicy=expand}",
+ "fl",
+ "score,id",
+ "sort",
+ "num_i asc"),
"*[count(//doc)=8]",
"//result/doc[1][str[@name='id'][.='p3s1'] and
float[@name='score'][.=57.0]]",
"//result/doc[2][str[@name='id'][.='z3'] and
float[@name='score'][.=45.0]]",
@@ -901,13 +972,18 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
// NOTE: this causes each boosted doc to be returned, but top level
sort is not score, so
// QEC doesn't hijack order
assertQ(
- req(
- "q", "*:* txt_t:XX",
- "qt", "/elevate",
- "elevateIds", "p3s3,z3,p3s4",
- "fq", "{!collapse " + opt + selector + " nullPolicy=expand}",
- "fl", "id",
- "sort", "num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "*:* txt_t:XX",
+ "elevateIds",
+ "p3s3,z3,p3s4",
+ "fq",
+ "{!collapse " + opt + selector + " nullPolicy=expand}",
+ "fl",
+ "id",
+ "sort",
+ "num_i asc"),
"*[count(//doc)=8]",
"//result/doc[1][str[@name='id'][.='z1']]",
"//result/doc[2][str[@name='id'][.='z2']]",
@@ -920,14 +996,20 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
);
// same query, w/forceElevation to change top level order
assertQ(
- req(
- "q", "*:* txt_t:XX",
- "qt", "/elevate",
- "elevateIds", "p3s3,z3,p3s4",
- "forceElevation", "true",
- "fq", "{!collapse " + opt + selector + " nullPolicy=expand}",
- "fl", "id",
- "sort", "num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "*:* txt_t:XX",
+ "elevateIds",
+ "p3s3,z3,p3s4",
+ "forceElevation",
+ "true",
+ "fq",
+ "{!collapse " + opt + selector + " nullPolicy=expand}",
+ "fl",
+ "id",
+ "sort",
+ "num_i asc"),
"*[count(//doc)=8]",
"//result/doc[1][str[@name='id'][.='p3s3']]", // 1234
"//result/doc[2][str[@name='id'][.='z3']]",
@@ -999,14 +1081,21 @@ public class TestBlockCollapse extends SolrTestCaseJ4 {
// score based collapse with boost to change p1 group head
assertQ(
- req(
- "q", "txt_t:XX", // only child docs with XX match
- "expand", "true",
- "qt", "/elevate",
- "elevateIds", "p1s1",
- "fl", "id",
- "fq", "{!collapse " + opt + nullPolicy + "}",
- "sort", "score desc, num_i asc"),
+ reqWithPath(
+ "/elevate",
+ "q",
+ "txt_t:XX",
+ // only child docs with XX match
+ "expand",
+ "true",
+ "elevateIds",
+ "p1s1",
+ "fl",
+ "id",
+ "fq",
+ "{!collapse " + opt + nullPolicy + "}",
+ "sort",
+ "score desc, num_i asc"),
"*[count(/response/result/doc)=3]",
"/response/result/doc[1]/str[@name='id'][.='p1s1']",
"/response/result/doc[2]/str[@name='id'][.='p2s4']",
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 5b674fd4cc7..d8284e1fd1d 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
@@ -183,11 +183,10 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
params.add("q", "*:*");
params.add("fq", "{!collapse field=group_s sort='term_s desc, test_l
asc'}");
params.add("sort", "test_l asc");
- params.add("qt", "/elevate");
params.add("forceElevation", "true");
params.add("elevateIds", "4");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=2]",
"//result/doc[1]/str[@name='id'][.='4']",
"//result/doc[2]/str[@name='id'][.='5']");
@@ -196,11 +195,10 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
params.add("q", "*:*");
params.add("fq", "{!collapse field=group_s sort='term_s desc, test_l
asc'}");
params.add("sort", "test_l asc");
- params.add("qt", "/elevate");
params.add("forceElevation", "true");
params.add("elevateIds", "7");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=2]",
"//result/doc[1]/str[@name='id'][.='7']",
"//result/doc[2]/str[@name='id'][.='1']");
@@ -567,9 +565,8 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
params.add("defType", "edismax");
params.add("bf", "field(test_i)");
params.add("qf", "term_s");
- params.add("qt", "/elevate");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=4]",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='2']",
@@ -586,10 +583,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
params.add("defType", "edismax");
params.add("bf", "field(test_i)");
params.add("qf", "term_s");
- params.add("qt", "/elevate");
params.add("elevateIds", "1,5");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=3]",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='5']",
@@ -605,10 +601,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
params.add("defType", "edismax");
params.add("bf", "field(test_i)");
params.add("qf", "term_s");
- params.add("qt", "/elevate");
params.add("elevateIds", "1,5");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=3]",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='5']",
@@ -624,10 +619,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
params.add("defType", "edismax");
params.add("bf", "field(test_i)");
params.add("qf", "term_s");
- params.add("qt", "/elevate");
params.add("elevateIds", "1,5");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=3]",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='5']",
@@ -641,10 +635,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
params.add("defType", "edismax");
params.add("bf", "field(test_i)");
params.add("qf", "term_s");
- params.add("qt", "/elevate");
params.add("elevateIds", "3,4");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=4]",
"//result/doc[1]/str[@name='id'][.='3']",
"//result/doc[2]/str[@name='id'][.='4']",
@@ -975,9 +968,8 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
params.add("defType", "edismax");
params.add("bf", "field(test_i)");
params.add("qf", "term_s");
- params.add("qt", "/elevate");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=3]",
"//result/doc[1]/str[@name='id'][.='3']",
"//result/doc[2]/str[@name='id'][.='6']",
@@ -1380,10 +1372,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
"//result/doc[3]/str[@name='id'][.='3']" // group B
);
assertQ(
- req(
+ reqWithPath(
+ "/elevate",
params(
- "qt",
- "/elevate",
"elevateIds",
"1,5",
"q",
@@ -1397,10 +1388,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
"//result/doc[4]/str[@name='id'][.='3']" // group B
);
assertQ(
- req(
+ reqWithPath(
+ "/elevate",
params(
- "qt",
- "/elevate",
"elevateIds",
"0,7",
"q",
@@ -1415,10 +1405,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
"//result/doc[5]/str[@name='id'][.='3']" // group B
);
assertQ(
- req(
+ reqWithPath(
+ "/elevate",
params(
- "qt",
- "/elevate",
"elevateIds",
"6,0",
"q",
@@ -1447,10 +1436,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
"//result/doc[4]/str[@name='id'][.='3']" // group B
);
assertQ(
- req(
+ reqWithPath(
+ "/elevate",
params(
- "qt",
- "/elevate",
"elevateIds",
"1,5",
"q",
@@ -1465,10 +1453,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
"//result/doc[5]/str[@name='id'][.='3']" // group B
);
assertQ(
- req(
+ reqWithPath(
+ "/elevate",
params(
- "qt",
- "/elevate",
"elevateIds",
"0,7",
"q",
@@ -1483,10 +1470,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
"//result/doc[5]/str[@name='id'][.='3']" // group B
);
assertQ(
- req(
+ reqWithPath(
+ "/elevate",
params(
- "qt",
- "/elevate",
"elevateIds",
"6,0",
"q",
@@ -1517,10 +1503,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
"//result/doc[6]/str[@name='id'][.='0']" // null
);
assertQ(
- req(
+ reqWithPath(
+ "/elevate",
params(
- "qt",
- "/elevate",
"elevateIds",
"1,5",
"q",
@@ -1537,10 +1522,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
"//result/doc[7]/str[@name='id'][.='0']" // null
);
assertQ(
- req(
+ reqWithPath(
+ "/elevate",
params(
- "qt",
- "/elevate",
"elevateIds",
"0,7",
"q",
@@ -1556,10 +1540,9 @@ public class TestCollapseQParserPlugin extends
SolrTestCaseJ4 {
"//result/doc[6]/str[@name='id'][.='3']" // group B
);
assertQ(
- req(
+ reqWithPath(
+ "/elevate",
params(
- "qt",
- "/elevate",
"elevateIds",
"6,0",
"q",
diff --git
a/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
b/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
index f3149af82bc..e674c92eb41 100644
--- a/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
@@ -491,10 +491,9 @@ public class TestReRankQParserPlugin extends
SolrTestCaseJ4 {
params.add("fl", "id,score");
params.add("start", "0");
params.add("rows", "10");
- params.add("qt", "/elevate");
params.add("elevateIds", "1");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=6]",
"//result/doc[1]/str[@name='id'][.='1']",
"//result/doc[2]/str[@name='id'][.='2']",
@@ -553,11 +552,10 @@ public class TestReRankQParserPlugin extends
SolrTestCaseJ4 {
params.add("fl", "id,score");
params.add("start", "0");
params.add("rows", "10");
- params.add("qt", "/elevate");
params.add("elevateIds", "1,4");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=6]",
"//result/doc[1]/str[@name='id'][.='1']", // Elevated
"//result/doc[2]/str[@name='id'][.='4']", // Elevated
@@ -585,11 +583,10 @@ public class TestReRankQParserPlugin extends
SolrTestCaseJ4 {
params.add("fl", "id,score");
params.add("start", "0");
params.add("rows", "10");
- params.add("qt", "/elevate");
params.add("elevateIds", "4,1");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=6]",
"//result/doc[1]/str[@name='id'][.='4']", // Elevated
"//result/doc[2]/str[@name='id'][.='1']", // Elevated
@@ -616,11 +613,10 @@ public class TestReRankQParserPlugin extends
SolrTestCaseJ4 {
params.add("fl", "id,score");
params.add("start", "0");
params.add("rows", "10");
- params.add("qt", "/elevate");
params.add("elevateIds", "4,1");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=6]",
"//result/doc[1]/str[@name='id'][.='4']", // Elevated
"//result/doc[2]/str[@name='id'][.='1']", // Elevated
@@ -649,11 +645,10 @@ public class TestReRankQParserPlugin extends
SolrTestCaseJ4 {
params.add("fl", "id,score");
params.add("start", "4");
params.add("rows", "10");
- params.add("qt", "/elevate");
params.add("elevateIds", "4,1");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=2]",
"//result/doc[1]/str[@name='id'][.='3']",
"//result/doc[2]/str[@name='id'][.='2']" // Was not in reRankDocs
@@ -678,10 +673,9 @@ public class TestReRankQParserPlugin extends
SolrTestCaseJ4 {
params.add("fl", "id,score");
params.add("start", "4");
params.add("rows", "10");
- params.add("qt", "/elevate");
params.add("elevateIds", "4,1");
- assertQ(req(params), "*[count(//doc)=0]");
+ assertQ(reqWithPath("/elevate", params), "*[count(//doc)=0]");
// Pass in reRankDocs lower than the length being collected.
params = new ModifiableSolrParams();
@@ -1095,11 +1089,10 @@ public class TestReRankQParserPlugin extends
SolrTestCaseJ4 {
params.add("fl", "id,score");
params.add("start", "0");
params.add("rows", "3");
- params.add("qt", "/elevate");
params.add("elevateIds", "1,4");
assertQ(
- req(params),
+ reqWithPath("/elevate", params),
"*[count(//doc)=3]",
"//result/doc[1]/str[@name='id'][.='1']", // Elevated
"//result/doc[2]/str[@name='id'][.='4']", // Elevated
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index 9665aac95b6..b3c50f8e151 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -848,15 +848,6 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
/** Validates a query matches some XPath test expressions and closes the
query */
public static void assertQ(String message, SolrQueryRequest req, String...
tests) {
- assertQ(message, req.getParams().get(CommonParams.QT), req, tests);
- }
-
- /**
- * Validates a query against the named handler matches some XPath test
expressions and closes the
- * query
- */
- public static void assertQ(
- String message, String handler, SolrQueryRequest req, String... tests) {
try {
String m = (null == message) ? "" : message + " "; // TODO log 'm' !!!
// since the default (standard) response format is now JSON
@@ -866,7 +857,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
// for tests, let's turn indention off so we don't have to handle
extraneous spaces
xmlWriterTypeParams.set("indent", xmlWriterTypeParams.get("indent",
"off"));
req.setParams(xmlWriterTypeParams);
- String response = h.query(handler, req);
+ String response = h.query(req);
if (req.getParams().getBool("facet", false)) {
// add a test to ensure that faceting did not throw an exception
@@ -1089,6 +1080,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase
{
}
}
+ /** Makes sure a query throws a SolrException with the listed response code
*/
public static void assertQEx(String message, SolrQueryRequest req,
SolrException.ErrorCode code) {
try {
ignoreException(".");
@@ -1310,6 +1302,37 @@ public abstract class SolrTestCaseJ4 extends
SolrTestCase {
return new SolrQueryRequestBase(h.getCore(), mp);
}
+ /**
+ * Generates a SolrQueryRequest representing the specified path and query
params
+ *
+ * <p>Path information is used by {@link #assertQ(SolrQueryRequest,
String...)} and similar
+ * helpers to look up the request handler to invoke. When used with these
helpers, typically only
+ * the requestHandler path segment need by provided ("/select", "/export",
etc.)
+ *
+ * @see #req(String...)
+ */
+ public static SolrQueryRequest reqWithPath(String path, String... params) {
+ return withPath(path, req(params));
+ }
+
+ /**
+ * Generates a SolrQueryRequest representing the specified path and query
params
+ *
+ * <p>Path information is used by {@link #assertQ(SolrQueryRequest,
String...)} and similar
+ * helpers to look up the request handler to invoke. When used with these
helpers, typically only
+ * the requestHandler path segment need by provided ("/select", "/export",
etc.)
+ *
+ * @see #req(SolrParams, String...)
+ */
+ public static SolrQueryRequest reqWithPath(String path, SolrParams params,
String... moreParams) {
+ return withPath(path, req(params, moreParams));
+ }
+
+ public static SolrQueryRequest withPath(String path, SolrQueryRequest req) {
+ req.getContext().put(CommonParams.PATH, path);
+ return req;
+ }
+
/** Necessary to make method signatures un-ambiguous */
public static class XmlDoc {
public String xml;
diff --git a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
index d4ff7bc3195..f0808526c0d 100644
--- a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
+++ b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
@@ -307,7 +307,9 @@ public class TestHarness extends BaseTestHarness {
* @see SolrQueryRequestBase
*/
public String query(SolrQueryRequest req) throws Exception {
- return query(req.getParams().get(CommonParams.QT), req);
+ String path = req.getPath();
+ String handler = path != null ? path :
req.getParams().get(CommonParams.QT);
+ return query(handler, req);
}
/**