From f1f2aef9be6c1975c74a56c55f8961abec104dc7 Mon Sep 17 00:00:00 2001 From: Jason Gerlowski Date: Fri, 7 Aug 2026 06:57:43 -0400 Subject: [PATCH 1/6] Add rh-aware overrides in SolrTestCaseJ4 methods --- .../java/org/apache/solr/SolrTestCaseJ4.java | 98 +++++++++++++++++-- 1 file changed, 91 insertions(+), 7 deletions(-) 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..323e392c0fc 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -900,6 +900,11 @@ public static void assertQ( /** Makes a query request and returns the JSON string response */ public static String JQ(SolrQueryRequest req) throws Exception { + return JQ(req.getParams().get(CommonParams.QT), req); + } + + /** Makes a query request against the named handler and returns the JSON string response */ + public static String JQ(String handler, SolrQueryRequest req) throws Exception { SolrParams params = req.getParams(); if (!"json".equals(params.get("wt", "xml")) || params.get("indent") == null) { ModifiableSolrParams newParams = new ModifiableSolrParams(params); @@ -911,7 +916,7 @@ public static String JQ(SolrQueryRequest req) throws Exception { String response; boolean failed = true; try { - response = h.query(req); + response = h.query(handler, req); failed = false; } finally { if (failed) { @@ -948,6 +953,19 @@ public static String assertJQ(SolrQueryRequest req, String... tests) throws Exce return assertJQ(req, JSONTestUtil.DEFAULT_DELTA, tests); } + /** + * Validates a query against the named handler matches some JSON test expressions using the + * default double delta tolerance. + * + * @see JSONTestUtil#DEFAULT_DELTA + * @see #assertJQ(String,SolrQueryRequest,double,String...) + * @return The request response as a JSON String if all test patterns pass + */ + public static String assertJQ(String handler, SolrQueryRequest req, String... tests) + throws Exception { + return assertJQ(handler, req, JSONTestUtil.DEFAULT_DELTA, tests); + } + /** * Validates a query matches some JSON test expressions and closes the query. The text expression * is of the form path:JSON. The Noggit JSON parser used accepts single quoted strings and bare @@ -963,6 +981,21 @@ public static String assertJQ(SolrQueryRequest req, String... tests) throws Exce */ public static String assertJQ(SolrQueryRequest req, double delta, String... tests) throws Exception { + return assertJQ(req.getParams().get(CommonParams.QT), req, delta, tests); + } + + /** + * Validates a query against the named handler matches some JSON test expressions and closes the + * query. + * + * @param handler the name of the request handler to process the request + * @param req Solr request to execute + * @param delta tolerance allowed in comparing float/double values + * @param tests JSON path expression + '==' + expected value + * @return The request response as a JSON String if all test patterns pass + */ + public static String assertJQ(String handler, SolrQueryRequest req, double delta, String... tests) + throws Exception { SolrParams params = null; try { params = req.getParams(); @@ -976,7 +1009,7 @@ public static String assertJQ(SolrQueryRequest req, double delta, String... test String response; boolean failed = true; try { - response = h.query(req); + response = h.query(handler, req); failed = false; } finally { if (failed) { @@ -1021,6 +1054,11 @@ public static String assertThatJQ(SolrQueryRequest req, Matcher test) thr return assertThatJQ(req, "", test); } + public static String assertThatJQ(String handler, SolrQueryRequest req, Matcher test) + throws Exception { + return assertThatJQ(handler, req, "", test); + } + /** * Validates a query completes and, using JSON deserialization, returns an object that passes the * given Matcher test. @@ -1033,9 +1071,24 @@ public static String assertThatJQ(SolrQueryRequest req, Matcher test) thr * @param test Matcher for the given object returned from deserializing the response * @return The request response as a JSON String if the test matcher passes */ - @SuppressWarnings("unchecked") public static String assertThatJQ(SolrQueryRequest req, String message, Matcher test) throws Exception { + return assertThatJQ(req.getParams().get(CommonParams.QT), req, message, test); + } + + /** + * Validates a query against the named handler completes and, using JSON deserialization, returns + * an object that passes the given Matcher test. + * + * @param handler the name of the request handler to process the request + * @param req Solr request to execute + * @param message Failure message for test + * @param test Matcher for the given object returned from deserializing the response + * @return The request response as a JSON String if the test matcher passes + */ + @SuppressWarnings("unchecked") + public static String assertThatJQ( + String handler, SolrQueryRequest req, String message, Matcher test) throws Exception { final SolrParams params = req.getParams(); try { if (!"json".equals(params.get("wt", "xml")) || params.get("indent") == null) { @@ -1048,7 +1101,7 @@ public static String assertThatJQ(SolrQueryRequest req, String message, Matc String response; boolean failed = true; try { - response = h.query(req); + response = h.query(handler, req); failed = false; } finally { if (failed) { @@ -1076,9 +1129,14 @@ public static String assertThatJQ(SolrQueryRequest req, String message, Matc /** Makes sure a query throws a SolrException with the listed response code */ public static void assertQEx(String message, SolrQueryRequest req, int code) { + assertQEx(message, req, code, req.getParams().get(CommonParams.QT)); + } + + /** Makes sure a query against the named handler throws a SolrException with the given code */ + public static void assertQEx(String message, SolrQueryRequest req, int code, String handler) { try { ignoreException("."); - h.query(req); + h.query(handler, req); fail(message); } catch (SolrException sex) { assertEquals(code, sex.code()); @@ -1090,9 +1148,15 @@ public static void assertQEx(String message, SolrQueryRequest req, int code) { } public static void assertQEx(String message, SolrQueryRequest req, SolrException.ErrorCode code) { + assertQEx(message, req, code, req.getParams().get(CommonParams.QT)); + } + + /** Makes sure a query against the named handler throws a SolrException with the given code */ + public static void assertQEx( + String message, SolrQueryRequest req, SolrException.ErrorCode code, String handler) { try { ignoreException("."); - h.query(req); + h.query(handler, req); fail(message); } catch (SolrException e) { assertEquals(code.code, e.code()); @@ -1117,9 +1181,29 @@ public static void assertQEx( String exceptionMessage, SolrQueryRequest req, SolrException.ErrorCode code) { + assertQEx(failMessage, exceptionMessage, req, code, req.getParams().get(CommonParams.QT)); + } + + /** + * Makes sure a query against the named handler throws a SolrException with the listed response + * code and expected message + * + * @param failMessage The assert message to show when the query doesn't throw the expected + * exception + * @param exceptionMessage A substring of the message expected in the exception + * @param req Solr request + * @param code expected error code for the query + * @param handler the name of the request handler to process the request + */ + public static void assertQEx( + String failMessage, + String exceptionMessage, + SolrQueryRequest req, + SolrException.ErrorCode code, + String handler) { try { ignoreException("."); - h.query(req); + h.query(handler, req); fail(failMessage); } catch (SolrException e) { assertEquals(code.code, e.code()); From 7e1db1e323a1ea5c67b7855282a743170c4f1d47 Mon Sep 17 00:00:00 2001 From: Jason Gerlowski Date: Sat, 8 Aug 2026 15:06:20 -0400 Subject: [PATCH 2/6] SOLR-18332: More qt-removal from tests, rd 3 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; passing the handler explicitly instead of embedding it as a 'qt' request param. --- .../org/apache/solr/TestCrossCoreJoin.java | 3 +- .../QueryElevationComponentTest.java | 239 +++++++----------- .../component/TermVectorComponentTest.java | 38 +-- .../handler/component/TermsComponentTest.java | 151 ++++++----- .../TestMatchedQueriesComponent.java | 27 +- .../apache/solr/search/TestBlockCollapse.java | 80 ++++-- .../search/TestCollapseQParserPlugin.java | 60 +++-- .../solr/search/TestReRankQParserPlugin.java | 21 +- 8 files changed, 289 insertions(+), 330 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..e88d948e2b3 100644 --- a/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java +++ b/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java @@ -151,9 +151,8 @@ void doTestJoin(String joinPrefix) throws Exception { "/response=={'numFound':3,'start':0,'numFoundExact':true,'docs':[{'id':'1'},{'id':'4'},{'id':'5'}]}"); assertJQ( + "/export", req( - "qt", - "/export", "q", joinPrefix + " from=dept_id_s to=dept_s fromIndex=fromCore}cat:dev", "fl", 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..4d99787e09a 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,8 @@ public void testFieldType() throws Exception { assertQ( "", - req( - CommonParams.Q, - "AAAA", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(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,9 +151,9 @@ public void testFq() throws Exception { // elevated docs 1, 2, and 3 are returned even though our query "ZZZZ" doesn't match them assertQ( "", + "/elevate", req( CommonParams.Q, "ZZZZ", - CommonParams.QT, "/elevate", CommonParams.FL, "id, score, [elevated]"), "//*[@numFound='3']", "//result/doc[1]/str[@name='id'][.='1']", @@ -172,9 +167,9 @@ public void testFq() throws Exception { // exclude docs 1 and 3 even though those docs are elevated assertQ( "", + "/elevate", req( CommonParams.Q, "ZZZZ", - CommonParams.QT, "/elevate", CommonParams.FL, "id, score, [elevated]", CommonParams.FQ, "str_s:b"), "//*[@numFound='1']", @@ -186,9 +181,9 @@ public void testFq() throws Exception { // docs assertQ( "", + "/elevate", 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"), @@ -200,9 +195,9 @@ public void testFq() throws Exception { // behavior as above; the filter still takes effect on the elevated docs assertQ( "", + "/elevate", req( CommonParams.Q, "ZZZZ", - CommonParams.QT, "/elevate", CommonParams.FL, "id, score, [elevated]", CommonParams.FQ, "{!tag=test1,test2}str_s:b", QueryElevationParams.ELEVATE_EXCLUDE_TAGS, ","), @@ -215,9 +210,9 @@ public void testFq() throws Exception { // the original filter assertQ( "", + "/elevate", 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"), @@ -233,9 +228,9 @@ public void testFq() throws Exception { // this case, the main query); nor does including empty values in the list of tags to exclude assertQ( "", + "/elevate", 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,,,"), @@ -250,9 +245,9 @@ public void testFq() throws Exception { // we can exclude some filters while leaving others in place assertQ( "", + "/elevate", 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", @@ -265,9 +260,9 @@ public void testFq() throws Exception { // when filters are marked as cache=false, tag exclusion works the same as before assertQ( "", + "/elevate", 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", @@ -280,9 +275,9 @@ public void testFq() throws Exception { // we can apply the same tag to two different filters assertQ( "", + "/elevate", 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", @@ -295,9 +290,9 @@ public void testFq() throws Exception { // we can use filter() syntax inside fq's that are tagged for exclusion assertQ( "", + "/elevate", 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)", @@ -310,9 +305,9 @@ public void testFq() throws Exception { // if we search for MMMM we should get one match; no documents are elevated for this query assertQ( "", + "/elevate", req( CommonParams.Q, "MMMM", - CommonParams.QT, "/elevate", CommonParams.FL, "id, score, [elevated]"), "//*[@numFound='1']", "//result/doc[1]/str[@name='id'][.='4']", @@ -321,9 +316,9 @@ public void testFq() throws Exception { // if we add fq=str_s:b, our one document that matches MMMM will be filtered out assertQ( "", + "/elevate", req( CommonParams.Q, "MMMM", - CommonParams.QT, "/elevate", CommonParams.FL, "id, score, [elevated]", CommonParams.FQ, "str_s:b"), "//*[@numFound='0']"); @@ -333,9 +328,9 @@ public void testFq() throws Exception { // subject to the filter assertQ( "", + "/elevate", req( CommonParams.Q, "MMMM", - CommonParams.QT, "/elevate", CommonParams.FL, "id, score, [elevated]", CommonParams.FQ, "{!tag=test1}str_s:b", QueryElevationParams.ELEVATE_EXCLUDE_TAGS, "test1"), @@ -345,9 +340,9 @@ public void testFq() throws Exception { // excluded; first, confirm that when collapsing, all elevated docs are visible by default assertQ( "", + "/elevate", req( CommonParams.Q, "ZZZZ", - CommonParams.QT, "/elevate", CommonParams.FL, "id, score, [elevated]", CommonParams.FQ, "{!collapse field=str_s sort='score desc'}"), "//*[@numFound='3']", @@ -361,9 +356,9 @@ public void testFq() throws Exception { // when collapsing, an added filter has the expected effect assertQ( "", + "/elevate", 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"), @@ -375,9 +370,9 @@ public void testFq() throws Exception { // elevated documents assertQ( "", + "/elevate", 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", @@ -396,12 +391,12 @@ public void testFq() throws Exception { "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"), - SolrException.ErrorCode.BAD_REQUEST); + SolrException.ErrorCode.BAD_REQUEST, + "/elevate"); // if a function range query is provided as a filter, it can be tagged for exclusion; // FunctionRangeQuery is special because it implements the PostFilter interface and @@ -410,9 +405,9 @@ public void testFq() throws Exception { // behavior assertQ( "", + "/elevate", 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", @@ -454,7 +449,6 @@ public void testFqWithCacheAndCostLocalParams() throws Exception { 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 +518,6 @@ public void testFqWithCacheAndCostLocalParams() throws Exception { try (SolrQueryRequest request = req( CommonParams.Q, "ZZZZ", - CommonParams.QT, "/elevate", CommonParams.DF, "text", CommonParams.FL, "id, score, [elevated]", CommonParams.FQ, "str_s:A", @@ -677,9 +670,9 @@ public void testGroupedQuery() throws Exception { assertQ( "non-elevated group query", + "/elevate", req( CommonParams.Q, "AAAA", - CommonParams.QT, "/elevate", GroupParams.GROUP_FIELD, "str_s", GroupParams.GROUP, "true", GroupParams.GROUP_TOTAL_COUNT, "true", @@ -703,9 +696,9 @@ public void testGroupedQuery() throws Exception { assertQ( "elevated group query", + "/elevate", req( CommonParams.Q, "AAAA", - CommonParams.QT, "/elevate", GroupParams.GROUP_FIELD, "str_s", GroupParams.GROUP, "true", GroupParams.GROUP_TOTAL_COUNT, "true", @@ -728,9 +721,9 @@ public void testGroupedQuery() throws Exception { assertQ( "non-elevated because sorted group query", + "/elevate", req( CommonParams.Q, "AAAA", - CommonParams.QT, "/elevate", CommonParams.SORT, "id asc", GroupParams.GROUP_FIELD, "str_s", GroupParams.GROUP, "true", @@ -754,9 +747,9 @@ public void testGroupedQuery() throws Exception { assertQ( "force-elevated sorted group query", + "/elevate", req( CommonParams.Q, "AAAA", - CommonParams.QT, "/elevate", CommonParams.SORT, "id asc", QueryElevationParams.FORCE_ELEVATION, "true", GroupParams.GROUP_FIELD, "str_s", @@ -781,9 +774,9 @@ public void testGroupedQuery() throws Exception { assertQ( "non-elevated because of sort within group query", + "/elevate", req( CommonParams.Q, "AAAA", - CommonParams.QT, "/elevate", CommonParams.SORT, "id asc", GroupParams.GROUP_SORT, "id desc", GroupParams.GROUP_FIELD, "str_s", @@ -808,9 +801,9 @@ public void testGroupedQuery() throws Exception { assertQ( "force elevated sort within sorted group query", + "/elevate", req( CommonParams.Q, "AAAA", - CommonParams.QT, "/elevate", CommonParams.SORT, "id asc", GroupParams.GROUP_SORT, "id desc", QueryElevationParams.FORCE_ELEVATION, "true", @@ -859,13 +852,8 @@ public void testTrieFieldType() throws Exception { assertQ( "", - req( - CommonParams.Q, - "AAAA", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(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 +921,8 @@ public void testInterface() throws Exception { assertQ( "Make sure QEC handles null queries", - req("qt", "/elevate", "q.alt", "*:*", "defType", "dismax"), + "/elevate", + req("q.alt", "*:*", "defType", "dismax"), "//*[@numFound='0']"); } } finally { @@ -957,13 +946,8 @@ public void testMarker() throws Exception { assertQ( "", - req( - CommonParams.Q, - "XXXX", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(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 +958,16 @@ public void testMarker() throws Exception { assertQ( "", - req( - CommonParams.Q, - "AAAA", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(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]"), + "/elevate", + req(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 +1001,10 @@ public void testMarkExcludes() throws Exception { assertQ( "", + "/elevate", req( CommonParams.Q, "XXXX XXXX", - CommonParams.QT, - "/elevate", QueryElevationParams.MARK_EXCLUDES, "true", "indent", @@ -1052,11 +1025,10 @@ public void testMarkExcludes() throws Exception { // thus, number 6 should not be returned, b/c it is excluded assertQ( "", + "/elevate", req( CommonParams.Q, "XXXX XXXX", - CommonParams.QT, - "/elevate", QueryElevationParams.MARK_EXCLUDES, "false", CommonParams.FL, @@ -1075,11 +1047,10 @@ public void testMarkExcludes() throws Exception { // excluded results) assertQ( "", + "/elevate", req( CommonParams.Q, "QQQQ", - CommonParams.QT, - "/elevate", QueryElevationParams.ENABLE, "false", "indent", @@ -1092,11 +1063,10 @@ public void testMarkExcludes() throws Exception { "//result/doc[3]/str[@name='id'][.='8']"); assertQ( "", + "/elevate", req( CommonParams.Q, "QQQQ", - CommonParams.QT, - "/elevate", QueryElevationParams.MARK_EXCLUDES, "true", "indent", @@ -1132,7 +1102,6 @@ public void testSorting() throws Exception { final SolrParams baseParams = params( - "qt", "/elevate", "q", query, "fl", "id,score", "indent", "true"); @@ -1143,6 +1112,7 @@ public void testSorting() throws Exception { assertQ( "Make sure standard sort works as expected", + "/elevate", req(baseParams), "//*[@numFound='3']", "//result/doc[1]/str[@name='id'][.='c']", @@ -1154,6 +1124,7 @@ public void testSorting() throws Exception { assertQ( "All six should make it", + "/elevate", req(baseParams), "//*[@numFound='6']", "//result/doc[1]/str[@name='id'][.='x']", @@ -1166,6 +1137,8 @@ public void testSorting() throws Exception { // now switch the order: booster.setTopQueryResults(reader, query, false, new String[] {"a", "x"}, null); assertQ( + null, + "/elevate", req(baseParams), "//*[@numFound='4']", "//result/doc[1]/str[@name='id'][.='a']", @@ -1177,6 +1150,8 @@ public void testSorting() throws Exception { // default 'forceBoost' should be false assertFalse(booster.forceElevation); assertQ( + null, + "/elevate", req(baseParams, "sort", "id asc"), "//*[@numFound='4']", "//result/doc[1]/str[@name='id'][.='a']", @@ -1186,6 +1161,7 @@ public void testSorting() throws Exception { assertQ( "useConfiguredElevatedOrder=false", + "/elevate", req(baseParams, "sort", "str_s1 asc,id desc", "useConfiguredElevatedOrder", "false"), "//*[@numFound='4']", "//result/doc[1]/str[@name='id'][.='x']", // group1 @@ -1195,6 +1171,8 @@ public void testSorting() throws Exception { booster.forceElevation = true; assertQ( + null, + "/elevate", req(baseParams, "sort", "id asc"), "//*[@numFound='4']", "//result/doc[1]/str[@name='id'][.='a']", @@ -1205,6 +1183,7 @@ public void testSorting() throws Exception { booster.forceElevation = true; assertQ( "useConfiguredElevatedOrder=false and forceElevation", + "/elevate", req(baseParams, "sort", "id desc", "useConfiguredElevatedOrder", "false"), "//*[@numFound='4']", "//result/doc[1]/str[@name='id'][.='x']", // force elevated @@ -1215,6 +1194,8 @@ public void testSorting() throws Exception { // Test exclusive (not to be confused with exclusion) booster.setTopQueryResults(reader, query, false, new String[] {"x", "a"}, new String[] {}); assertQ( + null, + "/elevate", req(baseParams, "exclusive", "true"), "//*[@numFound='2']", "//result/doc[1]/str[@name='id'][.='x']", @@ -1223,6 +1204,8 @@ public void testSorting() throws Exception { // Test exclusion booster.setTopQueryResults(reader, query, false, new String[] {"x"}, new String[] {"a"}); assertQ( + null, + "/elevate", req(baseParams), "//*[@numFound='3']", "//result/doc[1]/str[@name='id'][.='x']", @@ -1234,6 +1217,7 @@ public void testSorting() throws Exception { booster.clearElevationProviderCache(); assertQ( "All five should make it", + "/elevate", req(baseParams, "elevateIds", "x,y,z", "excludeIds", "b"), "//*[@numFound='5']", "//result/doc[1]/str[@name='id'][.='x']", @@ -1244,6 +1228,7 @@ public void testSorting() throws Exception { assertQ( "All four should make it", + "/elevate", req(baseParams, "elevateIds", "x,z,y", "excludeIds", "b,c"), "//*[@numFound='4']", "//result/doc[1]/str[@name='id'][.='x']", @@ -1363,37 +1348,22 @@ public void testWithLocalParam() throws Exception { assertQ( "", - req( - CommonParams.Q, - "AAAA", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(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, - "{!q.op=AND}AAAA", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(CommonParams.Q, "{!q.op=AND}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, - "{!q.op=AND v='AAAA'}", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(CommonParams.Q, "{!q.op=AND v='AAAA'}", CommonParams.FL, "id, score, [elevated]"), "//*[@numFound='1']", "//result/doc[1]/str[@name='id'][.='7']", "//result/doc[1]/bool[@name='[elevated]'][.='true']"); @@ -1425,13 +1395,8 @@ public void testQuerySubsetMatching() throws Exception { // Exact matching. assertQ( "", - req( - CommonParams.Q, - "XXXX", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(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 +1408,15 @@ public void testQuerySubsetMatching() throws Exception { // Exact matching. assertQ( "", - req( - CommonParams.Q, - "QQQQ EE", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(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]"), + "/elevate", + req(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 +1430,8 @@ public void testQuerySubsetMatching() throws Exception { // Subset + exact matching. assertQ( "", - req( - CommonParams.Q, - "BB CC", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(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,13 +1445,8 @@ public void testQuerySubsetMatching() throws Exception { // Subset matching. assertQ( "", - req( - CommonParams.Q, - "AA BB DD CC AA", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(CommonParams.Q, "AA BB DD CC AA", CommonParams.FL, "id, score, [elevated]"), "//*[@numFound='4']", "//result/doc[1]/str[@name='id'][.='10']", "//result/doc[2]/str[@name='id'][.='12']", @@ -1515,13 +1460,8 @@ public void testQuerySubsetMatching() throws Exception { // Subset matching. assertQ( "", - req( - CommonParams.Q, - "AA RR BB DD AA", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(CommonParams.Q, "AA RR BB DD AA", CommonParams.FL, "id, score, [elevated]"), "//*[@numFound='3']", "//result/doc[1]/str[@name='id'][.='12']", "//result/doc[2]/str[@name='id'][.='14']", @@ -1533,13 +1473,8 @@ public void testQuerySubsetMatching() throws Exception { // Subset matching. assertQ( "", - req( - CommonParams.Q, - "AA BB EE", - CommonParams.QT, - "/elevate", - CommonParams.FL, - "id, score, [elevated]"), + "/elevate", + req(CommonParams.Q, "AA BB EE", CommonParams.FL, "id, score, [elevated]"), "//*[@numFound='0']"); } finally { delete(); @@ -1598,9 +1533,9 @@ public void testOnlyDocsInSearchResultsWillBeElevated() throws Exception { // default behaviour assertQ( "", + "/elevate", req( CommonParams.Q, "YYYY", - CommonParams.QT, "/elevate", QueryElevationParams.ELEVATE_ONLY_DOCS_MATCHING_QUERY, "false", CommonParams.FL, "id, score, [elevated]"), "//*[@numFound='3']", @@ -1614,9 +1549,9 @@ public void testOnlyDocsInSearchResultsWillBeElevated() throws Exception { // only docs that matches q assertQ( "", + "/elevate", req( CommonParams.Q, "YYYY", - CommonParams.QT, "/elevate", QueryElevationParams.ELEVATE_ONLY_DOCS_MATCHING_QUERY, "true", CommonParams.FL, "id, score, [elevated]"), "//*[@numFound='2']", @@ -1644,9 +1579,9 @@ public void testOnlyRepresentativeIsVisibleWhenCollapsing() throws Exception { // default behaviour - all elevated docs are visible assertQ( "", + "/elevate", 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]"), @@ -1663,9 +1598,9 @@ public void testOnlyRepresentativeIsVisibleWhenCollapsing() throws Exception { // only representative elevated doc visible assertQ( "", + "/elevate", 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]"), @@ -1698,7 +1633,6 @@ public void testCursor() throws Exception { final SolrParams baseParams = params( - "qt", "/elevate", "q", "title:ipod", "sort", "score desc, id asc", "fl", "id", @@ -1707,12 +1641,14 @@ public void testCursor() throws Exception { // sanity check everything returned w/these elevation options... assertJQ( + "/elevate", req(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( + "/elevate", req(baseParams, CURSOR_MARK_PARAM, CURSOR_MARK_START), "/response/numFound==5", "/response/start==0", @@ -1722,18 +1658,21 @@ public void testCursor() throws Exception { String nextCursor = null; nextCursor = assertCursorJQ( + "/elevate", req(baseParams, CURSOR_MARK_PARAM, CURSOR_MARK_START, "rows", "2"), "/response/numFound==5", "/response/start==0", "/response/docs==[{'id':'x'},{'id':'y'}]"); nextCursor = assertCursorJQ( + "/elevate", req(baseParams, CURSOR_MARK_PARAM, nextCursor, "rows", "2"), "/response/numFound==5", "/response/start==0", "/response/docs==[{'id':'z'},{'id':'c'}]"); nextCursor = assertCursorJQ( + "/elevate", req(baseParams, CURSOR_MARK_PARAM, nextCursor, "rows", "2"), "/response/numFound==5", "/response/start==0", @@ -1741,6 +1680,7 @@ public void testCursor() throws Exception { final String lastCursor = nextCursor; nextCursor = assertCursorJQ( + "/elevate", req(baseParams, CURSOR_MARK_PARAM, nextCursor, "rows", "2"), "/response/numFound==5", "/response/start==0", @@ -1762,8 +1702,9 @@ private static Set toIdSet(String... ids) { * * @see #assertJQ */ - private static String assertCursorJQ(SolrQueryRequest req, String... tests) throws Exception { - String json = assertJQ(req, tests); + private static String assertCursorJQ(String handler, SolrQueryRequest req, String... tests) + throws Exception { + String json = assertJQ(handler, req, tests); Map rsp = (Map) fromJSONString(json); assertTrue( "response doesn't contain " + CURSOR_MARK_NEXT + ": " + json, 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..ba3b557b4ac 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 void testCanned() throws Exception { private void doBasics() throws Exception { assertJQ( + tv, req( "json.nl", "map", - "qt", - tv, "q", "id:0", TermVectorComponent.COMPONENT_NAME, @@ -246,11 +245,10 @@ private void doBasics() throws Exception { + " 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}}"); // tv.fl diff from fl assertJQ( + tv, req( "json.nl", "map", - "qt", - tv, "q", "id:0", "fl", @@ -266,11 +264,10 @@ private void doBasics() throws Exception { + " 'test_offtv':{'anoth':{'tf':1},'titl':{'tf':2}}}}"); // multi-valued tv.fl assertJQ( + tv, req( "json.nl", "map", - "qt", - tv, "q", "id:0", "fl", @@ -288,11 +285,10 @@ private void doBasics() throws Exception { + " 'test_offtv':{'anoth':{'tf':1},'titl':{'tf':2}}}}"); // re-use fl glob assertJQ( + tv, req( "json.nl", "map", - "qt", - tv, "q", "id:0", "fl", @@ -309,11 +305,10 @@ private void doBasics() throws Exception { + " 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}}"); // re-use fl, ignore things we can't handle assertJQ( + tv, req( "json.nl", "map", - "qt", - tv, "q", "id:0", "fl", @@ -327,11 +322,10 @@ private void doBasics() throws Exception { + " 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}}"); // re-use (multi-valued) fl, ignore things we can't handle assertJQ( + tv, req( "json.nl", "map", - "qt", - tv, "q", "id:0", "fl", @@ -349,11 +343,10 @@ private void doBasics() throws Exception { private void doOptions() throws Exception { assertJQ( + tv, req( "json.nl", "map", - "qt", - tv, "q", "id:0", TermVectorComponent.COMPONENT_NAME, @@ -371,11 +364,10 @@ private void doOptions() throws Exception { "/termVectors/0/test_posofftv/anoth=={'tf':1, 'offsets':{'start':20, 'end':27}, 'positions':{'position':5}, 'df':2, 'tf-idf':0.5}"); assertJQ( + tv, req( "json.nl", "map", - "qt", - tv, "q", "id:0", TermVectorComponent.COMPONENT_NAME, @@ -387,8 +379,7 @@ private void doOptions() throws Exception { // test each combination at random final List 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 @@ private void doOptions() throws Exception { } expected.append("}"); - assertJQ(req(list.toArray(new String[0])), expected.toString()); + assertJQ(tv, req(list.toArray(new String[0])), expected.toString()); } private void doPerField() throws Exception { assertJQ( + tv, req( "json.nl", "map", - "qt", - tv, "q", "id:0", TermVectorComponent.COMPONENT_NAME, @@ -462,11 +452,10 @@ private void doPayloads() throws Exception { // stuffs start (20) and end offset (27) into the // payload: assertJQ( + tv, req( "json.nl", "map", - "qt", - tv, "q", "id:0", TermVectorComponent.COMPONENT_NAME, @@ -498,11 +487,10 @@ public void testNoVectors() throws Exception { // 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( + tv, req( "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..fcd9d93c109 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,9 @@ public void createIndex() { @Test public void testEmptyLower() { assertQ( - req("indent", "true", "qt", "/terms", "terms.fl", "lowerfilt", "terms.upper", "b"), + null, + "/terms", + req("indent", "true", "terms.fl", "lowerfilt", "terms.upper", "b"), "count(//lst[@name='lowerfilt']/*)=6", "//int[@name='a'] ", "//int[@name='aa'] ", @@ -97,11 +99,11 @@ public void testEmptyLower() { @Test public void testMultipleFields() { assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "lowerfilt", "terms.upper", @@ -115,15 +117,17 @@ public void testMultipleFields() { @Test public void testUnlimitedRows() { assertQ( - req("indent", "true", "qt", "/terms", "terms.fl", "lowerfilt", "terms.fl", "standardfilt"), + null, + "/terms", + req("indent", "true", "terms.fl", "lowerfilt", "terms.fl", "standardfilt"), "count(//lst[@name='lowerfilt']/*)=9", "count(//lst[@name='standardfilt']/*)=10"); assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "lowerfilt", "terms.fl", @@ -137,11 +141,11 @@ public void testUnlimitedRows() { @Test public void testPrefix() { assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "lowerfilt", "terms.upper", @@ -165,11 +169,11 @@ public void testPrefix() { @Test public void testRegexp() { assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "standardfilt", "terms.lower", @@ -219,11 +223,11 @@ public void testRegexpFlagParsing() { public void testRegexpWithFlags() { // TODO: there are no uppercase or mixed-case terms in the index! assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "standardfilt", "terms.lower", @@ -244,11 +248,11 @@ public void testRegexpWithFlags() { @Test public void testSortCount() { assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "standardfilt", "terms.lower", @@ -269,11 +273,11 @@ public void testSortCount() { public void testTermsList() { // Terms list always returns in index order assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "standardfilt", "terms.list", @@ -287,7 +291,9 @@ public void testTermsList() { // Test with numeric terms assertQ( - req("indent", "true", "qt", "/terms", "terms.fl", "foo_i", "terms.list", "2,1"), + null, + "/terms", + req("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 +303,11 @@ public void testTermsList() { public void testStats() { // Terms list always returns in index order assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "standardfilt", "terms.stats", @@ -314,11 +320,11 @@ public void testStats() { @Test public void testSortIndex() { assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "standardfilt", "terms.lower", @@ -338,11 +344,11 @@ public void testSortIndex() { @Test public void testPastUpper() { assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "lowerfilt", // no upper bound, lower bound doesn't exist @@ -354,11 +360,11 @@ public void testPastUpper() { @Test public void testLowerExclusive() { assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "lowerfilt", "terms.lower", @@ -375,11 +381,11 @@ public void testLowerExclusive() { "//int[@name='abc'] "); assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "standardfilt", "terms.lower", @@ -394,17 +400,9 @@ public void testLowerExclusive() { @Test public void test() { assertQ( - req( - "indent", - "true", - "qt", - "/terms", - "terms.fl", - "lowerfilt", - "terms.lower", - "a", - "terms.upper", - "b"), + null, + "/terms", + req("indent", "true", "terms.fl", "lowerfilt", "terms.lower", "a", "terms.upper", "b"), "count(//lst[@name='lowerfilt']/*)=6", "//int[@name='a'] ", "//int[@name='aa'] ", @@ -414,11 +412,11 @@ public void test() { "//int[@name='abc'] "); assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "lowerfilt", "terms.lower", @@ -433,7 +431,7 @@ public void test() { "//int[@name='a']", "//int[@name='aa']"); - assertQ(req("indent", "true", "qt", "/terms", "terms.fl", "foo_i"), "//int[@name='1'][.='2']"); + assertQ(null, "/terms", req("indent", "true", "terms.fl", "foo_i"), "//int[@name='1'][.='2']"); /* terms.raw only applies to indexed fields assertQ(req("indent","true", "qt","/terms", @@ -444,18 +442,20 @@ public void test() { // check something at the end of the index assertQ( - req("indent", "true", "qt", "/terms", "terms.fl", "zzz_i"), + null, + "/terms", + req("indent", "true", "terms.fl", "zzz_i"), "count(//lst[@name='zzz_i']/*)=0"); } @Test public void testMinMaxFreq() { assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "lowerfilt", "terms.lower", @@ -469,11 +469,11 @@ public void testMinMaxFreq() { "count(//lst[@name='lowerfilt']/*)=1"); assertQ( + null, + "/terms", req( "indent", "true", - "qt", - "/terms", "terms.fl", "standardfilt", "terms.lower", @@ -490,23 +490,14 @@ public void testMinMaxFreq() { @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("/terms", req(params), "/terms/standardfilt/[0]==a", "/terms/standardfilt/[1]==1"); // enable terms.ttf params.set("terms.ttf", "true"); assertJQ( + "/terms", req(params), "/terms/standardfilt/[0]==a", "/terms/standardfilt/[1]/df==1", @@ -516,6 +507,7 @@ public void testTermsWithJSON() throws Exception { params.set("terms.list", "spider,snake,shark"); params.remove("terms.ttf"); assertJQ( + "/terms", req(params), "/terms/standardfilt/[0]==shark", "/terms/standardfilt/[1]==2", @@ -526,6 +518,7 @@ public void testTermsWithJSON() throws Exception { // with terms.list and terms.ttf=true params.set("terms.ttf", "true"); assertJQ( + "/terms", req(params), "/terms/standardfilt/[0]==shark", "/terms/standardfilt/[1]/df==2", @@ -543,11 +536,12 @@ public void testDocFreqAndTotalTermFreq() { SolrQueryRequest req = req( "indent", "true", - "qt", "/terms", "terms.fl", "standardfilt", "terms.ttf", "true", "terms.list", "snake,spider,shark,ddddd"); assertQ( + null, + "/terms", req, "count(//lst[@name='standardfilt']/*)=4", "//lst[@name='standardfilt']/lst[@name='ddddd']/long[@name='df'][.='4']", @@ -563,12 +557,13 @@ public void testDocFreqAndTotalTermFreq() { req = req( "indent", "true", - "qt", "/terms", "terms.fl", "standardfilt", "terms.ttf", "true", "terms.limit", "-1", "terms.sort", "count"); assertQ( + null, + "/terms", req, "count(//lst[@name='standardfilt']/*)>=4", // it would be at-least 4 "//lst[@name='standardfilt']/lst[@name='ddddd']/long[@name='df'][.='4']", @@ -586,11 +581,12 @@ public void testDocFreqAndTotalTermFreqForNonExistingTerm() { SolrQueryRequest req = req( "indent", "true", - "qt", "/terms", "terms.fl", "standardfilt", "terms.ttf", "true", "terms.list", "boo,snake"); assertQ( + null, + "/terms", req, "count(//lst[@name='standardfilt']/*)=1", "//lst[@name='standardfilt']/lst[@name='snake']/long[@name='df'][.='3']", @@ -602,12 +598,13 @@ public void testDocFreqAndTotalTermFreqForMultipleFields() { SolrQueryRequest req = req( "indent", "true", - "qt", "/terms", "terms.fl", "lowerfilt", "terms.fl", "standardfilt", "terms.ttf", "true", "terms.list", "a,aa,aaa"); assertQ( + null, + "/terms", req, "count(//lst[@name='lowerfilt']/*)=3", "count(//lst[@name='standardfilt']/*)=3", @@ -628,13 +625,14 @@ public void testDocFreqAndTotalTermFreqForMultipleFields() { req = req( "indent", "true", - "qt", "/terms", "terms.fl", "lowerfilt", "terms.fl", "standardfilt", "terms.ttf", "true", "terms.sort", "index", "terms.limit", "10"); assertQ( + null, + "/terms", req, "count(//lst[@name='lowerfilt']/*)<=10", "count(//lst[@name='standardfilt']/*)<=10", @@ -689,10 +687,7 @@ public void testPointField() throws Exception { 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,17 +772,9 @@ public void testPointField() throws Exception { assertEquals(i, nvals); assertQ( - req( - "indent", - "true", - "qt", - "/terms", - "terms.fl", - "foo_pi", - "terms.sort", - "index", - "terms.limit", - "2"), + null, + "/terms", + req("indent", "true", "terms.fl", "foo_pi", "terms.sort", "index", "terms.limit", "2"), "count(//lst[@name='foo_pi']/*)=2", "//lst[@name='foo_pi']/int[1][@name='" + val1 + "']", "//lst[@name='foo_pi']/int[2][@name='" + val2 + "']"); @@ -834,7 +821,9 @@ public void testDatePointField() { assertU(commit()); assertQ( - req("indent", "true", "qt", "/terms", "terms.fl", "foo_pdt", "terms.sort", "count"), + null, + "/terms", + req("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 +833,9 @@ public void testDatePointField() { assertU(commit()); assertQ( - req("indent", "true", "qt", "/terms", "terms.fl", "foo_pdt", "terms.sort", "count"), + null, + "/terms", + req("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..fa7e7aaf717 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,8 @@ public static void beforeClass() throws Exception { @Test public void testNotEnabledByDefault() throws Exception { assertJQ( - req("qt", HANDLER, "q", "{!term name=fantasy_cat f=cat_s}fantasy", "sort", "id asc"), + HANDLER, + req("q", "{!term name=fantasy_cat f=cat_s}fantasy", "sort", "id asc"), "!/matched_queries_per_hit==null", "!/matched_queries_summary==null"); } @@ -56,8 +57,8 @@ public void testNotEnabledByDefault() throws Exception { @Test public void testSingleNamedTermQuery() throws Exception { assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "{!term name=fantasy_cat f=cat_s}fantasy", "matched_queries", "true", "sort", "id asc", @@ -75,8 +76,8 @@ public void testSingleNamedTermQuery() throws Exception { @Test public void testShortParamAlias() throws Exception { assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "{!term name=fantasy_cat f=cat_s}fantasy", "mq", "true", "sort", "id asc", @@ -92,8 +93,8 @@ public void testShortParamAlias() throws Exception { @Test public void testTwoNamedQueriesOr() throws Exception { assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "({!term name=fantasy_cat f=cat_s}fantasy) OR ({!term name=scifi_cat f=cat_s}scifi)", "matched_queries", "true", @@ -110,8 +111,8 @@ public void testTwoNamedQueriesOr() throws Exception { @Test public void testUnnamedQueryProducesNoOutput() throws Exception { assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "{!term f=cat_s}fantasy", "matched_queries", "true", "sort", "id asc", @@ -126,8 +127,8 @@ public void testUnnamedQueryProducesNoOutput() throws Exception { public void testMultiValuedFieldBothNamesPresent() throws Exception { // docs 2 and 3 match both fantasy_cat and childrens_cat assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "({!term name=fantasy_cat f=cat_s}fantasy) OR ({!term name=childrens_cat f=cat_s}childrens)", "matched_queries", "true", @@ -146,8 +147,8 @@ public void testMultiValuedFieldBothNamesPresent() throws Exception { @Test public void testTermsNamedQuery() throws Exception { assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "{!terms name=genre_all f=cat_s}fantasy,scifi", "matched_queries", "true", "sort", "id asc", @@ -167,8 +168,8 @@ public void testTermsNamedQuery() throws Exception { @Test public void testBoolOuterAndInnerNamesComposed() throws Exception { assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "{!bool name=all_books" + " should='{!term name=fantasy_cat f=cat_s}fantasy'" @@ -198,8 +199,8 @@ public void testBoolOuterAndInnerNamesComposed() throws Exception { @Test public void testBoolMultipleShouldNamedTerms() throws Exception { assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "{!bool should='{!term name=fantasy_cat f=cat_s}fantasy'" + " should='{!term name=scifi_cat f=cat_s}scifi'}", @@ -225,8 +226,8 @@ public void testBoolMultipleShouldNamedTerms() throws Exception { public void testBoolMustWithNamedShould() throws Exception { // MUST: all 4 fantasy docs; named SHOULD: only docs 2 and 3 (childrens) assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "{!bool must='{!term f=cat_s}fantasy'" + " should='{!term name=childrens_cat f=cat_s}childrens'}", @@ -251,8 +252,8 @@ public void testBoolMustWithNamedShould() throws Exception { @Test public void testPrefixNamedQuery() throws Exception { assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "{!prefix name=fanta_prefix f=cat_s}fanta", "matched_queries", "true", "sort", "id asc", @@ -269,8 +270,8 @@ public void testPrefixNamedQuery() throws Exception { @Test public void testEdismaxNamedQuery() throws Exception { assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "{!edismax name=fantasy_edismax qf=cat_s}fantasy", "matched_queries", "true", "sort", "id asc", @@ -287,8 +288,8 @@ public void testEdismaxNamedQuery() throws Exception { @Test public void testLuceneNamedQuery() throws Exception { assertJQ( + HANDLER, req( - "qt", HANDLER, "q", "{!lucene name=scifi_lucene df=cat_s}scifi", "matched_queries", "true", "sort", "id asc", 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..acbd029fd10 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 void testPostFilterIntrospection() throws Exception { 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,17 @@ public void testSimple() { // same query, but boosting a diff p1 sku to change group head (and result order) assertQ( + null, + "/elevate", req( - "q", q, - "qt", "/elevate", - "elevateIds", "p1s1", - "fq", "{!collapse " + opt + nullPolicy + "}", - "sort", "score desc, num_i asc"), + "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 +365,17 @@ public void testSimple() { // same query, but boosting multiple skus from p1 assertQ( + null, + "/elevate", req( - "q", q, - "qt", "/elevate", - "elevateIds", "p1s1,p1s2", - "fq", "{!collapse " + opt + nullPolicy + "}", - "sort", "score desc, num_i asc"), + "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,9 +396,10 @@ public void testSimple() { "//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( + null, + "/elevate", req( "q", "{!func}sum(42, num_i)", - "qt", "/elevate", "elevateIds", "p1s1", "fq", "{!collapse " + opt + nullPolicy + "}", "fl", "score,id", @@ -399,9 +410,10 @@ public void testSimple() { "//result/doc[3][str[@name='id'][.='p2s3'] and float[@name='score'][.=141.0]]"); // same query, but boosting multiple skus from p1 assertQ( + null, + "/elevate", req( "q", "{!func}sum(42, num_i)", - "qt", "/elevate", "elevateIds", "p1s2,p1s1", "fq", "{!collapse " + opt + nullPolicy + "}", "fl", "score,id", @@ -467,9 +479,10 @@ public void testSimple() { "//result/doc[3]/str[@name='id'][.='p2s2']"); // same query, but boosting skus to change group head (and result order) assertQ( + null, + "/elevate", req( "q", "txt_t:* txt_t:XX", - "qt", "/elevate", "elevateIds", "p2s3,p1s1", "fq", "{!collapse " + opt + selector + nullPolicy + "}", "sort", "score desc, num_i asc"), @@ -479,9 +492,10 @@ public void testSimple() { "//result/doc[3]/str[@name='id'][.='p3s4']"); // same query, but boosting multiple skus from p1 assertQ( + null, + "/elevate", req( "q", "txt_t:* txt_t:XX", - "qt", "/elevate", "elevateIds", "p2s3,p1s4,p1s3", "fq", "{!collapse " + opt + selector + nullPolicy + "}", "sort", "score desc, num_i asc"), @@ -525,9 +539,10 @@ public void testSimple() { "//result/doc[3][str[@name='id'][.='p3s3'] and float[@name='score'][.=1276.0]]"); // same query, but boosting multiple skus from p1 assertQ( + null, + "/elevate", req( "q", "{!func}sum(42, num_i)", - "qt", "/elevate", "elevateIds", "p1s2,p1s1", "fq", "{!collapse " + opt + selector + nullPolicy + "}", "fl", "score,id", @@ -565,9 +580,10 @@ public void testSimple() { // NOTE: this causes each boosted doc to be returned, but top level sort is not score, // so QEC doesn't hijack order assertQ( + null, + "/elevate", req( "q", "*:* txt_t:XX", - "qt", "/elevate", "elevateIds", "p3s3,p3s2", "fq", "{!collapse " + opt + selector + nullPolicy + "}", "fl", "id", @@ -581,9 +597,10 @@ public void testSimple() { "//result/doc[4][str[@name='id'][.='p3s3']]"); // same query, w/forceElevation to change top level order assertQ( + null, + "/elevate", req( "q", "*:* txt_t:XX", - "qt", "/elevate", "elevateIds", "p3s3,p3s2", "forceElevation", "true", "fq", "{!collapse " + opt + selector + nullPolicy + "}", @@ -654,9 +671,10 @@ public void testNullPolicyExpand() { "//result/doc[7]/str[@name='id'][.='z100']"); // same query, but boosting docs to change group heads (and result order) assertQ( + null, + "/elevate", req( "q", "*:* txt_t:XX", - "qt", "/elevate", "elevateIds", "z2,p3s3", "fq", "{!collapse " + opt + " nullPolicy=expand}", "sort", "score desc, num_i asc"), @@ -686,9 +704,10 @@ public void testNullPolicyExpand() { "//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( + null, + "/elevate", req( "q", "{!func}sum(42, num_i)", - "qt", "/elevate", "elevateIds", "p2s4,z2,p2s1", "fq", "{!collapse " + opt + " nullPolicy=expand}", "fl", "score,id", @@ -758,9 +777,10 @@ public void testNullPolicyExpand() { // NOTE: this causes each boosted doc to be returned, but top level sort is not score, so // QEC doesn't hijack order assertQ( + null, + "/elevate", req( "q", "num_i:* txt_t:XX", - "qt", "/elevate", "elevateIds", "p3s3,z3,p3s1", "fq", "{!collapse " + opt + selector + " nullPolicy=expand}", "sort", "num_i asc"), @@ -775,9 +795,10 @@ public void testNullPolicyExpand() { "//result/doc[8]/str[@name='id'][.='p3s3']"); // same query, w/forceElevation to change top level order assertQ( + null, + "/elevate", req( "q", "num_i:* txt_t:XX", - "qt", "/elevate", "elevateIds", "p3s3,z3,p3s1", "forceElevation", "true", "fq", "{!collapse " + opt + selector + " nullPolicy=expand}", @@ -832,9 +853,10 @@ public void testNullPolicyExpand() { // NOTE: this causes each boosted doc to be returned, but top level sort is not score, so // QEC doesn't hijack order assertQ( + null, + "/elevate", req( "q", "{!func}sum(42, num_i)", - "qt", "/elevate", "elevateIds", "p3s1,z3,p3s4", "fq", "{!collapse " + opt + selector + " nullPolicy=expand}", "fl", "score,id", @@ -850,9 +872,10 @@ public void testNullPolicyExpand() { "//result/doc[8][str[@name='id'][.='p1s3'] and float[@name='score'][.=819.0]]"); // same query, w/forceElevation to change top level order assertQ( + null, + "/elevate", req( "q", "{!func}sum(42, num_i)", - "qt", "/elevate", "elevateIds", "p3s1,z3,p3s4", "forceElevation", "true", "fq", "{!collapse " + opt + selector + " nullPolicy=expand}", @@ -901,9 +924,10 @@ public void testNullPolicyExpand() { // NOTE: this causes each boosted doc to be returned, but top level sort is not score, so // QEC doesn't hijack order assertQ( + null, + "/elevate", req( "q", "*:* txt_t:XX", - "qt", "/elevate", "elevateIds", "p3s3,z3,p3s4", "fq", "{!collapse " + opt + selector + " nullPolicy=expand}", "fl", "id", @@ -920,9 +944,10 @@ public void testNullPolicyExpand() { ); // same query, w/forceElevation to change top level order assertQ( + null, + "/elevate", req( "q", "*:* txt_t:XX", - "qt", "/elevate", "elevateIds", "p3s3,z3,p3s4", "forceElevation", "true", "fq", "{!collapse " + opt + selector + " nullPolicy=expand}", @@ -999,10 +1024,11 @@ public void testBlockCollapseWithExpandComponent() { // score based collapse with boost to change p1 group head assertQ( + null, + "/elevate", req( "q", "txt_t:XX", // only child docs with XX match "expand", "true", - "qt", "/elevate", "elevateIds", "p1s1", "fl", "id", "fq", "{!collapse " + opt + nullPolicy + "}", 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..1db1027bff7 100644 --- a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java +++ b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java @@ -183,10 +183,11 @@ public void testMultiSort() { 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( + null, + "/elevate", req(params), "*[count(//doc)=2]", "//result/doc[1]/str[@name='id'][.='4']", @@ -196,10 +197,11 @@ public void testMultiSort() { 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( + null, + "/elevate", req(params), "*[count(//doc)=2]", "//result/doc[1]/str[@name='id'][.='7']", @@ -567,8 +569,9 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { params.add("defType", "edismax"); params.add("bf", "field(test_i)"); params.add("qf", "term_s"); - params.add("qt", "/elevate"); assertQ( + null, + "/elevate", req(params), "*[count(//doc)=4]", "//result/doc[1]/str[@name='id'][.='1']", @@ -586,9 +589,10 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { 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( + null, + "/elevate", req(params), "*[count(//doc)=3]", "//result/doc[1]/str[@name='id'][.='1']", @@ -605,9 +609,10 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { 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( + null, + "/elevate", req(params), "*[count(//doc)=3]", "//result/doc[1]/str[@name='id'][.='1']", @@ -624,9 +629,10 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { 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( + null, + "/elevate", req(params), "*[count(//doc)=3]", "//result/doc[1]/str[@name='id'][.='1']", @@ -641,9 +647,10 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { 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( + null, + "/elevate", req(params), "*[count(//doc)=4]", "//result/doc[1]/str[@name='id'][.='3']", @@ -975,8 +982,9 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { params.add("defType", "edismax"); params.add("bf", "field(test_i)"); params.add("qf", "term_s"); - params.add("qt", "/elevate"); assertQ( + null, + "/elevate", req(params), "*[count(//doc)=3]", "//result/doc[1]/str[@name='id'][.='3']", @@ -1380,10 +1388,10 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[3]/str[@name='id'][.='3']" // group B ); assertQ( + null, + "/elevate", req( params( - "qt", - "/elevate", "elevateIds", "1,5", "q", @@ -1397,10 +1405,10 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[4]/str[@name='id'][.='3']" // group B ); assertQ( + null, + "/elevate", req( params( - "qt", - "/elevate", "elevateIds", "0,7", "q", @@ -1415,10 +1423,10 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[5]/str[@name='id'][.='3']" // group B ); assertQ( + null, + "/elevate", req( params( - "qt", - "/elevate", "elevateIds", "6,0", "q", @@ -1447,10 +1455,10 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[4]/str[@name='id'][.='3']" // group B ); assertQ( + null, + "/elevate", req( params( - "qt", - "/elevate", "elevateIds", "1,5", "q", @@ -1465,10 +1473,10 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[5]/str[@name='id'][.='3']" // group B ); assertQ( + null, + "/elevate", req( params( - "qt", - "/elevate", "elevateIds", "0,7", "q", @@ -1483,10 +1491,10 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[5]/str[@name='id'][.='3']" // group B ); assertQ( + null, + "/elevate", req( params( - "qt", - "/elevate", "elevateIds", "6,0", "q", @@ -1517,10 +1525,10 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[6]/str[@name='id'][.='0']" // null ); assertQ( + null, + "/elevate", req( params( - "qt", - "/elevate", "elevateIds", "1,5", "q", @@ -1537,10 +1545,10 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[7]/str[@name='id'][.='0']" // null ); assertQ( + null, + "/elevate", req( params( - "qt", - "/elevate", "elevateIds", "0,7", "q", @@ -1556,10 +1564,10 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[6]/str[@name='id'][.='3']" // group B ); assertQ( + null, + "/elevate", req( 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..389447d20e4 100644 --- a/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java +++ b/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java @@ -491,9 +491,10 @@ public void testReRankQueries() { params.add("fl", "id,score"); params.add("start", "0"); params.add("rows", "10"); - params.add("qt", "/elevate"); params.add("elevateIds", "1"); assertQ( + null, + "/elevate", req(params), "*[count(//doc)=6]", "//result/doc[1]/str[@name='id'][.='1']", @@ -553,10 +554,11 @@ public void testReRankQueries() { params.add("fl", "id,score"); params.add("start", "0"); params.add("rows", "10"); - params.add("qt", "/elevate"); params.add("elevateIds", "1,4"); assertQ( + null, + "/elevate", req(params), "*[count(//doc)=6]", "//result/doc[1]/str[@name='id'][.='1']", // Elevated @@ -585,10 +587,11 @@ public void testReRankQueries() { params.add("fl", "id,score"); params.add("start", "0"); params.add("rows", "10"); - params.add("qt", "/elevate"); params.add("elevateIds", "4,1"); assertQ( + null, + "/elevate", req(params), "*[count(//doc)=6]", "//result/doc[1]/str[@name='id'][.='4']", // Elevated @@ -616,10 +619,11 @@ public void testReRankQueries() { params.add("fl", "id,score"); params.add("start", "0"); params.add("rows", "10"); - params.add("qt", "/elevate"); params.add("elevateIds", "4,1"); assertQ( + null, + "/elevate", req(params), "*[count(//doc)=6]", "//result/doc[1]/str[@name='id'][.='4']", // Elevated @@ -649,10 +653,11 @@ public void testReRankQueries() { params.add("fl", "id,score"); params.add("start", "4"); params.add("rows", "10"); - params.add("qt", "/elevate"); params.add("elevateIds", "4,1"); assertQ( + null, + "/elevate", req(params), "*[count(//doc)=2]", "//result/doc[1]/str[@name='id'][.='3']", @@ -678,10 +683,9 @@ public void testReRankQueries() { 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(null, "/elevate", req(params), "*[count(//doc)=0]"); // Pass in reRankDocs lower than the length being collected. params = new ModifiableSolrParams(); @@ -1095,10 +1099,11 @@ public void testOverRank() { params.add("fl", "id,score"); params.add("start", "0"); params.add("rows", "3"); - params.add("qt", "/elevate"); params.add("elevateIds", "1,4"); assertQ( + null, + "/elevate", req(params), "*[count(//doc)=3]", "//result/doc[1]/str[@name='id'][.='1']", // Elevated From b5e66296a035144e169cedd752120196cd601292 Mon Sep 17 00:00:00 2001 From: Jason Gerlowski Date: Mon, 10 Aug 2026 07:26:54 -0400 Subject: [PATCH 3/6] Replace existing pattern with reqWithPath --- .../org/apache/solr/TestCrossCoreJoin.java | 4 +- .../solr/handler/MoreLikeThisHandlerTest.java | 19 +- .../QueryElevationComponentTest.java | 663 ++++++++++-------- .../component/TermVectorComponentTest.java | 46 +- .../handler/component/TermsComponentTest.java | 244 +++---- .../TestMatchedQueriesComponent.java | 198 +++--- .../apache/solr/search/TestBlockCollapse.java | 331 +++++---- .../search/TestCollapseQParserPlugin.java | 77 +- .../solr/search/TestReRankQParserPlugin.java | 26 +- .../java/org/apache/solr/SolrTestCaseJ4.java | 146 ++-- 10 files changed, 945 insertions(+), 809 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java b/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java index e88d948e2b3..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,8 @@ void doTestJoin(String joinPrefix) throws Exception { "/response=={'numFound':3,'start':0,'numFoundExact':true,'docs':[{'id':'1'},{'id':'4'},{'id':'5'}]}"); assertJQ( - "/export", - req( + reqWithPath( + "/export", "q", joinPrefix + " from=dept_id_s to=dept_s fromIndex=fromCore}cat:dev", "fl", 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 void testInterface() { // 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 void testInterface() { 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 void testMultifieldSimilarity() { 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 4d99787e09a..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,8 +118,7 @@ public void testFieldType() throws Exception { assertQ( "", - "/elevate", - req(CommonParams.Q, "AAAA", 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']", @@ -151,10 +150,7 @@ public void testFq() throws Exception { // elevated docs 1, 2, and 3 are returned even though our query "ZZZZ" doesn't match them assertQ( "", - "/elevate", - req( - CommonParams.Q, "ZZZZ", - 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']", @@ -167,11 +163,14 @@ public void testFq() throws Exception { // exclude docs 1 and 3 even though those docs are elevated assertQ( "", - "/elevate", - req( - CommonParams.Q, "ZZZZ", - 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']"); @@ -181,12 +180,16 @@ public void testFq() throws Exception { // docs assertQ( "", - "/elevate", - req( - CommonParams.Q, "ZZZZ", - 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']"); @@ -195,12 +198,16 @@ public void testFq() throws Exception { // behavior as above; the filter still takes effect on the elevated docs assertQ( "", - "/elevate", - req( - CommonParams.Q, "ZZZZ", - 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']"); @@ -210,12 +217,16 @@ public void testFq() throws Exception { // the original filter assertQ( "", - "/elevate", - req( - CommonParams.Q, "ZZZZ", - 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']", @@ -228,12 +239,16 @@ public void testFq() throws Exception { // this case, the main query); nor does including empty values in the list of tags to exclude assertQ( "", - "/elevate", - req( - 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,,,"), + 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']", @@ -245,14 +260,20 @@ public void testFq() throws Exception { // we can exclude some filters while leaving others in place assertQ( "", - "/elevate", - req( - 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"), + 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']"); @@ -260,14 +281,20 @@ public void testFq() throws Exception { // when filters are marked as cache=false, tag exclusion works the same as before assertQ( "", - "/elevate", - req( - 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"), + 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']"); @@ -275,14 +302,20 @@ public void testFq() throws Exception { // we can apply the same tag to two different filters assertQ( "", - "/elevate", - req( - 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"), + 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']"); @@ -290,13 +323,18 @@ public void testFq() throws Exception { // we can use filter() syntax inside fq's that are tagged for exclusion assertQ( "", - "/elevate", - req( - 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"), + 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']"); @@ -305,10 +343,7 @@ public void testFq() throws Exception { // if we search for MMMM we should get one match; no documents are elevated for this query assertQ( "", - "/elevate", - req( - CommonParams.Q, "MMMM", - 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']"); @@ -316,11 +351,14 @@ public void testFq() throws Exception { // if we add fq=str_s:b, our one document that matches MMMM will be filtered out assertQ( "", - "/elevate", - req( - CommonParams.Q, "MMMM", - 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 @@ -328,23 +366,30 @@ public void testFq() throws Exception { // subject to the filter assertQ( "", - "/elevate", - req( - CommonParams.Q, "MMMM", - 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( "", - "/elevate", - req( - CommonParams.Q, "ZZZZ", - 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']", @@ -356,12 +401,16 @@ public void testFq() throws Exception { // when collapsing, an added filter has the expected effect assertQ( "", - "/elevate", - req( - CommonParams.Q, "ZZZZ", - 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']"); @@ -370,13 +419,18 @@ public void testFq() throws Exception { // elevated documents assertQ( "", - "/elevate", - req( - 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"), + 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']", @@ -389,14 +443,19 @@ public void testFq() throws Exception { // user should be informed assertQEx( "tagging a collapse filter for exclusion should lead to a BAD_REQUEST", - req( - 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, - "/elevate"); + 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; // FunctionRangeQuery is special because it implements the PostFilter interface and @@ -405,13 +464,18 @@ public void testFq() throws Exception { // behavior assertQ( "", - "/elevate", - req( - 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"), + 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']", @@ -670,15 +734,22 @@ public void testGroupedQuery() throws Exception { assertQ( "non-elevated group query", - "/elevate", - req( - 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]"), + 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']", @@ -696,14 +767,20 @@ public void testGroupedQuery() throws Exception { assertQ( "elevated group query", - "/elevate", - req( - 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]"), + 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']", @@ -721,15 +798,22 @@ public void testGroupedQuery() throws Exception { assertQ( "non-elevated because sorted group query", - "/elevate", - req( - 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]"), + 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']", @@ -747,16 +831,24 @@ public void testGroupedQuery() throws Exception { assertQ( "force-elevated sorted group query", - "/elevate", - req( - 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]"), + 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']", @@ -774,16 +866,24 @@ public void testGroupedQuery() throws Exception { assertQ( "non-elevated because of sort within group query", - "/elevate", - req( - 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]"), + 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']", @@ -801,17 +901,26 @@ public void testGroupedQuery() throws Exception { assertQ( "force elevated sort within sorted group query", - "/elevate", - req( - 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]"), + 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']", @@ -852,8 +961,7 @@ public void testTrieFieldType() throws Exception { assertQ( "", - "/elevate", - req(CommonParams.Q, "AAAA", 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']", @@ -921,8 +1029,7 @@ public void testInterface() throws Exception { assertQ( "Make sure QEC handles null queries", - "/elevate", - req("q.alt", "*:*", "defType", "dismax"), + reqWithPath("/elevate", "q.alt", "*:*", "defType", "dismax"), "//*[@numFound='0']"); } } finally { @@ -946,8 +1053,7 @@ public void testMarker() throws Exception { assertQ( "", - "/elevate", - req(CommonParams.Q, "XXXX", 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']", @@ -958,16 +1064,14 @@ public void testMarker() throws Exception { assertQ( "", - "/elevate", - req(CommonParams.Q, "AAAA", 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( "", - "/elevate", - req(CommonParams.Q, "AAAA", 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'])", @@ -1001,8 +1105,8 @@ public void testMarkExcludes() throws Exception { assertQ( "", - "/elevate", - req( + reqWithPath( + "/elevate", CommonParams.Q, "XXXX XXXX", QueryElevationParams.MARK_EXCLUDES, @@ -1025,8 +1129,8 @@ public void testMarkExcludes() throws Exception { // thus, number 6 should not be returned, b/c it is excluded assertQ( "", - "/elevate", - req( + reqWithPath( + "/elevate", CommonParams.Q, "XXXX XXXX", QueryElevationParams.MARK_EXCLUDES, @@ -1047,8 +1151,8 @@ public void testMarkExcludes() throws Exception { // excluded results) assertQ( "", - "/elevate", - req( + reqWithPath( + "/elevate", CommonParams.Q, "QQQQ", QueryElevationParams.ENABLE, @@ -1063,8 +1167,8 @@ public void testMarkExcludes() throws Exception { "//result/doc[3]/str[@name='id'][.='8']"); assertQ( "", - "/elevate", - req( + reqWithPath( + "/elevate", CommonParams.Q, "QQQQ", QueryElevationParams.MARK_EXCLUDES, @@ -1112,8 +1216,7 @@ public void testSorting() throws Exception { assertQ( "Make sure standard sort works as expected", - "/elevate", - req(baseParams), + reqWithPath("/elevate", baseParams), "//*[@numFound='3']", "//result/doc[1]/str[@name='id'][.='c']", "//result/doc[2]/str[@name='id'][.='b']", @@ -1124,8 +1227,7 @@ public void testSorting() throws Exception { assertQ( "All six should make it", - "/elevate", - req(baseParams), + reqWithPath("/elevate", baseParams), "//*[@numFound='6']", "//result/doc[1]/str[@name='id'][.='x']", "//result/doc[2]/str[@name='id'][.='y']", @@ -1137,9 +1239,7 @@ public void testSorting() throws Exception { // now switch the order: booster.setTopQueryResults(reader, query, false, new String[] {"a", "x"}, null); assertQ( - null, - "/elevate", - req(baseParams), + reqWithPath("/elevate", baseParams), "//*[@numFound='4']", "//result/doc[1]/str[@name='id'][.='a']", "//result/doc[2]/str[@name='id'][.='x']", @@ -1150,9 +1250,7 @@ public void testSorting() throws Exception { // default 'forceBoost' should be false assertFalse(booster.forceElevation); assertQ( - null, - "/elevate", - 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']", @@ -1161,8 +1259,13 @@ public void testSorting() throws Exception { assertQ( "useConfiguredElevatedOrder=false", - "/elevate", - 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 @@ -1171,9 +1274,7 @@ public void testSorting() throws Exception { booster.forceElevation = true; assertQ( - null, - "/elevate", - 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']", @@ -1183,8 +1284,8 @@ public void testSorting() throws Exception { booster.forceElevation = true; assertQ( "useConfiguredElevatedOrder=false and forceElevation", - "/elevate", - 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 @@ -1194,9 +1295,7 @@ public void testSorting() throws Exception { // Test exclusive (not to be confused with exclusion) booster.setTopQueryResults(reader, query, false, new String[] {"x", "a"}, new String[] {}); assertQ( - null, - "/elevate", - 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']"); @@ -1204,9 +1303,7 @@ public void testSorting() throws Exception { // Test exclusion booster.setTopQueryResults(reader, query, false, new String[] {"x"}, new String[] {"a"}); assertQ( - null, - "/elevate", - req(baseParams), + reqWithPath("/elevate", baseParams), "//*[@numFound='3']", "//result/doc[1]/str[@name='id'][.='x']", "//result/doc[2]/str[@name='id'][.='c']", @@ -1217,8 +1314,7 @@ public void testSorting() throws Exception { booster.clearElevationProviderCache(); assertQ( "All five should make it", - "/elevate", - 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']", @@ -1228,8 +1324,7 @@ public void testSorting() throws Exception { assertQ( "All four should make it", - "/elevate", - 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']", @@ -1348,22 +1443,29 @@ public void testWithLocalParam() throws Exception { assertQ( "", - "/elevate", - req(CommonParams.Q, "AAAA", 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( "", - "/elevate", - req(CommonParams.Q, "{!q.op=AND}AAAA", CommonParams.FL, "id, score, [elevated]"), + reqWithPath( + "/elevate", + CommonParams.Q, + "{!q.op=AND}AAAA", + CommonParams.FL, + "id, score, [elevated]"), "//*[@numFound='1']", "//result/doc[1]/str[@name='id'][.='7']", "//result/doc[1]/bool[@name='[elevated]'][.='true']"); assertQ( "", - "/elevate", - req(CommonParams.Q, "{!q.op=AND v='AAAA'}", CommonParams.FL, "id, score, [elevated]"), + reqWithPath( + "/elevate", + CommonParams.Q, + "{!q.op=AND v='AAAA'}", + CommonParams.FL, + "id, score, [elevated]"), "//*[@numFound='1']", "//result/doc[1]/str[@name='id'][.='7']", "//result/doc[1]/bool[@name='[elevated]'][.='true']"); @@ -1395,8 +1497,7 @@ public void testQuerySubsetMatching() throws Exception { // Exact matching. assertQ( "", - "/elevate", - req(CommonParams.Q, "XXXX", 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']", @@ -1408,15 +1509,15 @@ public void testQuerySubsetMatching() throws Exception { // Exact matching. assertQ( "", - "/elevate", - req(CommonParams.Q, "QQQQ EE", CommonParams.FL, "id, score, [elevated]"), + reqWithPath( + "/elevate", CommonParams.Q, "QQQQ EE", CommonParams.FL, "id, score, [elevated]"), "//*[@numFound='0']"); // Subset matching. assertQ( "", - "/elevate", - req(CommonParams.Q, "BB DD CC VV", 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']", @@ -1430,8 +1531,8 @@ public void testQuerySubsetMatching() throws Exception { // Subset + exact matching. assertQ( "", - "/elevate", - req(CommonParams.Q, "BB CC", 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']", @@ -1445,8 +1546,12 @@ public void testQuerySubsetMatching() throws Exception { // Subset matching. assertQ( "", - "/elevate", - req(CommonParams.Q, "AA BB DD CC AA", CommonParams.FL, "id, score, [elevated]"), + reqWithPath( + "/elevate", + CommonParams.Q, + "AA BB DD CC AA", + CommonParams.FL, + "id, score, [elevated]"), "//*[@numFound='4']", "//result/doc[1]/str[@name='id'][.='10']", "//result/doc[2]/str[@name='id'][.='12']", @@ -1460,8 +1565,12 @@ public void testQuerySubsetMatching() throws Exception { // Subset matching. assertQ( "", - "/elevate", - req(CommonParams.Q, "AA RR BB DD AA", CommonParams.FL, "id, score, [elevated]"), + reqWithPath( + "/elevate", + CommonParams.Q, + "AA RR BB DD AA", + CommonParams.FL, + "id, score, [elevated]"), "//*[@numFound='3']", "//result/doc[1]/str[@name='id'][.='12']", "//result/doc[2]/str[@name='id'][.='14']", @@ -1473,8 +1582,8 @@ public void testQuerySubsetMatching() throws Exception { // Subset matching. assertQ( "", - "/elevate", - req(CommonParams.Q, "AA BB EE", CommonParams.FL, "id, score, [elevated]"), + reqWithPath( + "/elevate", CommonParams.Q, "AA BB EE", CommonParams.FL, "id, score, [elevated]"), "//*[@numFound='0']"); } finally { delete(); @@ -1533,11 +1642,14 @@ public void testOnlyDocsInSearchResultsWillBeElevated() throws Exception { // default behaviour assertQ( "", - "/elevate", - req( - CommonParams.Q, "YYYY", - 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']", @@ -1549,11 +1661,14 @@ public void testOnlyDocsInSearchResultsWillBeElevated() throws Exception { // only docs that matches q assertQ( "", - "/elevate", - req( - CommonParams.Q, "YYYY", - 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']", @@ -1579,12 +1694,16 @@ public void testOnlyRepresentativeIsVisibleWhenCollapsing() throws Exception { // default behaviour - all elevated docs are visible assertQ( "", - "/elevate", - req( - CommonParams.Q, "ZZZZ", - 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']", @@ -1598,12 +1717,16 @@ public void testOnlyRepresentativeIsVisibleWhenCollapsing() throws Exception { // only representative elevated doc visible assertQ( "", - "/elevate", - req( - CommonParams.Q, "ZZZZ", - 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']", @@ -1641,15 +1764,13 @@ public void testCursor() throws Exception { // sanity check everything returned w/these elevation options... assertJQ( - "/elevate", - 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( - "/elevate", - 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'}]"); @@ -1658,30 +1779,27 @@ public void testCursor() throws Exception { String nextCursor = null; nextCursor = assertCursorJQ( - "/elevate", - 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( - "/elevate", - 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( - "/elevate", - 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( - "/elevate", - 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==[]"); @@ -1702,9 +1820,8 @@ private static Set toIdSet(String... ids) { * * @see #assertJQ */ - private static String assertCursorJQ(String handler, SolrQueryRequest req, String... tests) - throws Exception { - String json = assertJQ(handler, req, tests); + private static String assertCursorJQ(SolrQueryRequest req, String... tests) throws Exception { + String json = assertJQ(req, tests); Map rsp = (Map) fromJSONString(json); assertTrue( "response doesn't contain " + CURSOR_MARK_NEXT + ": " + json, 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 ba3b557b4ac..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,8 +227,8 @@ public void testCanned() throws Exception { private void doBasics() throws Exception { assertJQ( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", @@ -245,8 +245,8 @@ private void doBasics() throws Exception { + " 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}}"); // tv.fl diff from fl assertJQ( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", @@ -264,8 +264,8 @@ private void doBasics() throws Exception { + " 'test_offtv':{'anoth':{'tf':1},'titl':{'tf':2}}}}"); // multi-valued tv.fl assertJQ( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", @@ -285,8 +285,8 @@ private void doBasics() throws Exception { + " 'test_offtv':{'anoth':{'tf':1},'titl':{'tf':2}}}}"); // re-use fl glob assertJQ( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", @@ -305,8 +305,8 @@ private void doBasics() throws Exception { + " 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}}"); // re-use fl, ignore things we can't handle assertJQ( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", @@ -322,8 +322,8 @@ private void doBasics() throws Exception { + " 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}}"); // re-use (multi-valued) fl, ignore things we can't handle assertJQ( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", @@ -343,8 +343,8 @@ private void doBasics() throws Exception { private void doOptions() throws Exception { assertJQ( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", @@ -364,8 +364,8 @@ private void doOptions() throws Exception { "/termVectors/0/test_posofftv/anoth=={'tf':1, 'offsets':{'start':20, 'end':27}, 'positions':{'position':5}, 'df':2, 'tf-idf':0.5}"); assertJQ( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", @@ -404,13 +404,13 @@ private void doOptions() throws Exception { } expected.append("}"); - assertJQ(tv, req(list.toArray(new String[0])), expected.toString()); + assertJQ(reqWithPath(tv, list.toArray(new String[0])), expected.toString()); } private void doPerField() throws Exception { assertJQ( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", @@ -452,8 +452,8 @@ private void doPayloads() throws Exception { // stuffs start (20) and end offset (27) into the // payload: assertJQ( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", @@ -487,8 +487,8 @@ public void testNoVectors() throws Exception { // 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( - tv, - req( + reqWithPath( + tv, "json.nl", "map", "q", 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 fcd9d93c109..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,9 +84,7 @@ public void createIndex() { @Test public void testEmptyLower() { assertQ( - null, - "/terms", - req("indent", "true", "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'] ", @@ -99,9 +97,8 @@ public void testEmptyLower() { @Test public void testMultipleFields() { assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -117,15 +114,13 @@ public void testMultipleFields() { @Test public void testUnlimitedRows() { assertQ( - null, - "/terms", - req("indent", "true", "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( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -141,9 +136,8 @@ public void testUnlimitedRows() { @Test public void testPrefix() { assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -169,9 +163,8 @@ public void testPrefix() { @Test public void testRegexp() { assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -223,9 +216,8 @@ public void testRegexpFlagParsing() { public void testRegexpWithFlags() { // TODO: there are no uppercase or mixed-case terms in the index! assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -248,9 +240,8 @@ public void testRegexpWithFlags() { @Test public void testSortCount() { assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -273,9 +264,8 @@ public void testSortCount() { public void testTermsList() { // Terms list always returns in index order assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -291,9 +281,7 @@ public void testTermsList() { // Test with numeric terms assertQ( - null, - "/terms", - req("indent", "true", "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']"); @@ -303,9 +291,8 @@ public void testTermsList() { public void testStats() { // Terms list always returns in index order assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -320,9 +307,8 @@ public void testStats() { @Test public void testSortIndex() { assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -344,9 +330,8 @@ public void testSortIndex() { @Test public void testPastUpper() { assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -360,9 +345,8 @@ public void testPastUpper() { @Test public void testLowerExclusive() { assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -381,9 +365,8 @@ public void testLowerExclusive() { "//int[@name='abc'] "); assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -400,9 +383,16 @@ public void testLowerExclusive() { @Test public void test() { assertQ( - null, - "/terms", - req("indent", "true", "terms.fl", "lowerfilt", "terms.lower", "a", "terms.upper", "b"), + reqWithPath( + "/terms", + "indent", + "true", + "terms.fl", + "lowerfilt", + "terms.lower", + "a", + "terms.upper", + "b"), "count(//lst[@name='lowerfilt']/*)=6", "//int[@name='a'] ", "//int[@name='aa'] ", @@ -412,9 +402,8 @@ public void test() { "//int[@name='abc'] "); assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -424,36 +413,34 @@ public void test() { "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(null, "/terms", req("indent", "true", "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( - null, - "/terms", - req("indent", "true", "terms.fl", "zzz_i"), + reqWithPath("/terms", "indent", "true", "terms.fl", "zzz_i"), "count(//lst[@name='zzz_i']/*)=0"); } @Test public void testMinMaxFreq() { assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -469,9 +456,8 @@ public void testMinMaxFreq() { "count(//lst[@name='lowerfilt']/*)=1"); assertQ( - null, - "/terms", - req( + reqWithPath( + "/terms", "indent", "true", "terms.fl", @@ -492,13 +478,13 @@ public void testTermsWithJSON() throws Exception { ModifiableSolrParams params = params("terms.fl", "standardfilt", "terms.lower", "a", "terms.sort", "index", "wt", "json"); - assertJQ("/terms", 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( - "/terms", - req(params), + reqWithPath("/terms", params), "/terms/standardfilt/[0]==a", "/terms/standardfilt/[1]/df==1", "/terms/standardfilt/[1]/ttf==1"); @@ -507,8 +493,7 @@ public void testTermsWithJSON() throws Exception { params.set("terms.list", "spider,snake,shark"); params.remove("terms.ttf"); assertJQ( - "/terms", - req(params), + reqWithPath("/terms", params), "/terms/standardfilt/[0]==shark", "/terms/standardfilt/[1]==2", "/terms/standardfilt/[2]==snake", @@ -518,8 +503,7 @@ public void testTermsWithJSON() throws Exception { // with terms.list and terms.ttf=true params.set("terms.ttf", "true"); assertJQ( - "/terms", - req(params), + reqWithPath("/terms", params), "/terms/standardfilt/[0]==shark", "/terms/standardfilt/[1]/df==2", "/terms/standardfilt/[1]/ttf==2", @@ -534,14 +518,17 @@ public void testTermsWithJSON() throws Exception { @Test public void testDocFreqAndTotalTermFreq() { SolrQueryRequest req = - req( - "indent", "true", - "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( - null, - "/terms", req, "count(//lst[@name='standardfilt']/*)=4", "//lst[@name='standardfilt']/lst[@name='ddddd']/long[@name='df'][.='4']", @@ -555,15 +542,19 @@ public void testDocFreqAndTotalTermFreq() { // terms.limit=-1 and terms.sort=count and NO terms.list req = - req( - "indent", "true", - "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( - null, - "/terms", req, "count(//lst[@name='standardfilt']/*)>=4", // it would be at-least 4 "//lst[@name='standardfilt']/lst[@name='ddddd']/long[@name='df'][.='4']", @@ -579,14 +570,17 @@ public void testDocFreqAndTotalTermFreq() { @Test public void testDocFreqAndTotalTermFreqForNonExistingTerm() { SolrQueryRequest req = - req( - "indent", "true", - "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( - null, - "/terms", req, "count(//lst[@name='standardfilt']/*)=1", "//lst[@name='standardfilt']/lst[@name='snake']/long[@name='df'][.='3']", @@ -596,15 +590,19 @@ public void testDocFreqAndTotalTermFreqForNonExistingTerm() { @Test public void testDocFreqAndTotalTermFreqForMultipleFields() { SolrQueryRequest req = - req( - "indent", "true", - "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( - null, - "/terms", req, "count(//lst[@name='lowerfilt']/*)=3", "count(//lst[@name='standardfilt']/*)=3", @@ -623,16 +621,21 @@ public void testDocFreqAndTotalTermFreqForMultipleFields() { // terms.ttf=true, terms.sort=index and no terms list req = - req( - "indent", "true", - "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( - null, - "/terms", req, "count(//lst[@name='lowerfilt']/*)<=10", "count(//lst[@name='standardfilt']/*)<=10", @@ -772,9 +775,16 @@ public void testPointField() throws Exception { assertEquals(i, nvals); assertQ( - null, - "/terms", - req("indent", "true", "terms.fl", "foo_pi", "terms.sort", "index", "terms.limit", "2"), + reqWithPath( + "/terms", + "indent", + "true", + "terms.fl", + "foo_pi", + "terms.sort", + "index", + "terms.limit", + "2"), "count(//lst[@name='foo_pi']/*)=2", "//lst[@name='foo_pi']/int[1][@name='" + val1 + "']", "//lst[@name='foo_pi']/int[2][@name='" + val2 + "']"); @@ -821,9 +831,7 @@ public void testDatePointField() { assertU(commit()); assertQ( - null, - "/terms", - req("indent", "true", "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']"); @@ -833,9 +841,7 @@ public void testDatePointField() { assertU(commit()); assertQ( - null, - "/terms", - req("indent", "true", "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 fa7e7aaf717..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,8 +47,7 @@ public static void beforeClass() throws Exception { @Test public void testNotEnabledByDefault() throws Exception { assertJQ( - HANDLER, - req("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"); } @@ -57,12 +56,16 @@ public void testNotEnabledByDefault() throws Exception { @Test public void testSingleNamedTermQuery() throws Exception { assertJQ( - HANDLER, - req( - "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'", @@ -76,12 +79,16 @@ public void testSingleNamedTermQuery() throws Exception { @Test public void testShortParamAlias() throws Exception { assertJQ( - HANDLER, - req( - "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'"); } @@ -93,13 +100,16 @@ public void testShortParamAlias() throws Exception { @Test public void testTwoNamedQueriesOr() throws Exception { assertJQ( - HANDLER, - req( + 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'", @@ -111,12 +121,16 @@ public void testTwoNamedQueriesOr() throws Exception { @Test public void testUnnamedQueryProducesNoOutput() throws Exception { assertJQ( - HANDLER, - req( - "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"); @@ -127,13 +141,16 @@ public void testUnnamedQueryProducesNoOutput() throws Exception { public void testMultiValuedFieldBothNamesPresent() throws Exception { // docs 2 and 3 match both fantasy_cat and childrens_cat assertJQ( - HANDLER, - req( + 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'", @@ -147,12 +164,16 @@ public void testMultiValuedFieldBothNamesPresent() throws Exception { @Test public void testTermsNamedQuery() throws Exception { assertJQ( - HANDLER, - req( - "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'", @@ -168,15 +189,18 @@ public void testTermsNamedQuery() throws Exception { @Test public void testBoolOuterAndInnerNamesComposed() throws Exception { assertJQ( - HANDLER, - req( + 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'", @@ -199,14 +223,17 @@ public void testBoolOuterAndInnerNamesComposed() throws Exception { @Test public void testBoolMultipleShouldNamedTerms() throws Exception { assertJQ( - HANDLER, - req( + 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'", @@ -226,14 +253,17 @@ public void testBoolMultipleShouldNamedTerms() throws Exception { public void testBoolMustWithNamedShould() throws Exception { // MUST: all 4 fantasy docs; named SHOULD: only docs 2 and 3 (childrens) assertJQ( - HANDLER, - req( + 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'", @@ -252,12 +282,16 @@ public void testBoolMustWithNamedShould() throws Exception { @Test public void testPrefixNamedQuery() throws Exception { assertJQ( - HANDLER, - req( - "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'", @@ -270,12 +304,16 @@ public void testPrefixNamedQuery() throws Exception { @Test public void testEdismaxNamedQuery() throws Exception { assertJQ( - HANDLER, - req( - "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'", @@ -288,12 +326,16 @@ public void testEdismaxNamedQuery() throws Exception { @Test public void testLuceneNamedQuery() throws Exception { assertJQ( - HANDLER, - req( - "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 acbd029fd10..92a5d523b7e 100644 --- a/solr/core/src/test/org/apache/solr/search/TestBlockCollapse.java +++ b/solr/core/src/test/org/apache/solr/search/TestBlockCollapse.java @@ -347,9 +347,8 @@ public void testSimple() { // same query, but boosting a diff p1 sku to change group head (and result order) assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", "q", q, "elevateIds", @@ -365,9 +364,8 @@ public void testSimple() { // same query, but boosting multiple skus from p1 assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", "q", q, "elevateIds", @@ -396,28 +394,36 @@ public void testSimple() { "//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( - null, - "/elevate", - req( - "q", "{!func}sum(42, num_i)", - "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( - null, - "/elevate", - req( - "q", "{!func}sum(42, num_i)", - "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]]", @@ -479,26 +485,32 @@ public void testSimple() { "//result/doc[3]/str[@name='id'][.='p2s2']"); // same query, but boosting skus to change group head (and result order) assertQ( - null, - "/elevate", - req( - "q", "txt_t:* txt_t:XX", - "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( - null, - "/elevate", - req( - "q", "txt_t:* txt_t:XX", - "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']", @@ -539,14 +551,18 @@ public void testSimple() { "//result/doc[3][str[@name='id'][.='p3s3'] and float[@name='score'][.=1276.0]]"); // same query, but boosting multiple skus from p1 assertQ( - null, - "/elevate", - req( - "q", "{!func}sum(42, num_i)", - "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]]", @@ -580,14 +596,18 @@ public void testSimple() { // NOTE: this causes each boosted doc to be returned, but top level sort is not score, // so QEC doesn't hijack order assertQ( - null, - "/elevate", - req( - "q", "*:* txt_t:XX", - "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) @@ -597,15 +617,20 @@ public void testSimple() { "//result/doc[4][str[@name='id'][.='p3s3']]"); // same query, w/forceElevation to change top level order assertQ( - null, - "/elevate", - req( - "q", "*:* txt_t:XX", - "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']]", @@ -671,13 +696,16 @@ public void testNullPolicyExpand() { "//result/doc[7]/str[@name='id'][.='z100']"); // same query, but boosting docs to change group heads (and result order) assertQ( - null, - "/elevate", - req( - "q", "*:* txt_t:XX", - "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']", @@ -704,14 +732,18 @@ public void testNullPolicyExpand() { "//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( - null, - "/elevate", - req( - "q", "{!func}sum(42, num_i)", - "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]]", @@ -777,13 +809,16 @@ public void testNullPolicyExpand() { // NOTE: this causes each boosted doc to be returned, but top level sort is not score, so // QEC doesn't hijack order assertQ( - null, - "/elevate", - req( - "q", "num_i:* txt_t:XX", - "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']", @@ -795,14 +830,18 @@ public void testNullPolicyExpand() { "//result/doc[8]/str[@name='id'][.='p3s3']"); // same query, w/forceElevation to change top level order assertQ( - null, - "/elevate", - req( - "q", "num_i:* txt_t:XX", - "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']", @@ -853,14 +892,18 @@ public void testNullPolicyExpand() { // NOTE: this causes each boosted doc to be returned, but top level sort is not score, so // QEC doesn't hijack order assertQ( - null, - "/elevate", - req( - "q", "{!func}sum(42, num_i)", - "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]]", @@ -872,15 +915,20 @@ public void testNullPolicyExpand() { "//result/doc[8][str[@name='id'][.='p1s3'] and float[@name='score'][.=819.0]]"); // same query, w/forceElevation to change top level order assertQ( - null, - "/elevate", - req( - "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"), + 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]]", @@ -924,14 +972,18 @@ public void testNullPolicyExpand() { // NOTE: this causes each boosted doc to be returned, but top level sort is not score, so // QEC doesn't hijack order assertQ( - null, - "/elevate", - req( - "q", "*:* txt_t:XX", - "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']]", @@ -944,15 +996,20 @@ public void testNullPolicyExpand() { ); // same query, w/forceElevation to change top level order assertQ( - null, - "/elevate", - req( - "q", "*:* txt_t:XX", - "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']]", @@ -1024,15 +1081,21 @@ public void testBlockCollapseWithExpandComponent() { // score based collapse with boost to change p1 group head assertQ( - null, - "/elevate", - req( - "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"), + 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 1db1027bff7..d8284e1fd1d 100644 --- a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java +++ b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java @@ -186,9 +186,7 @@ public void testMultiSort() { params.add("forceElevation", "true"); params.add("elevateIds", "4"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=2]", "//result/doc[1]/str[@name='id'][.='4']", "//result/doc[2]/str[@name='id'][.='5']"); @@ -200,9 +198,7 @@ public void testMultiSort() { params.add("forceElevation", "true"); params.add("elevateIds", "7"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=2]", "//result/doc[1]/str[@name='id'][.='7']", "//result/doc[2]/str[@name='id'][.='1']"); @@ -570,9 +566,7 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { params.add("bf", "field(test_i)"); params.add("qf", "term_s"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=4]", "//result/doc[1]/str[@name='id'][.='1']", "//result/doc[2]/str[@name='id'][.='2']", @@ -591,9 +585,7 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { params.add("qf", "term_s"); params.add("elevateIds", "1,5"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=3]", "//result/doc[1]/str[@name='id'][.='1']", "//result/doc[2]/str[@name='id'][.='5']", @@ -611,9 +603,7 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { params.add("qf", "term_s"); params.add("elevateIds", "1,5"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=3]", "//result/doc[1]/str[@name='id'][.='1']", "//result/doc[2]/str[@name='id'][.='5']", @@ -631,9 +621,7 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { params.add("qf", "term_s"); params.add("elevateIds", "1,5"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=3]", "//result/doc[1]/str[@name='id'][.='1']", "//result/doc[2]/str[@name='id'][.='5']", @@ -649,9 +637,7 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { params.add("qf", "term_s"); params.add("elevateIds", "3,4"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=4]", "//result/doc[1]/str[@name='id'][.='3']", "//result/doc[2]/str[@name='id'][.='4']", @@ -983,9 +969,7 @@ private void testCollapseQueries(String group, String hint, boolean numeric) { params.add("bf", "field(test_i)"); params.add("qf", "term_s"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=3]", "//result/doc[1]/str[@name='id'][.='3']", "//result/doc[2]/str[@name='id'][.='6']", @@ -1388,9 +1372,8 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[3]/str[@name='id'][.='3']" // group B ); assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", params( "elevateIds", "1,5", @@ -1405,9 +1388,8 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[4]/str[@name='id'][.='3']" // group B ); assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", params( "elevateIds", "0,7", @@ -1423,9 +1405,8 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[5]/str[@name='id'][.='3']" // group B ); assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", params( "elevateIds", "6,0", @@ -1455,9 +1436,8 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[4]/str[@name='id'][.='3']" // group B ); assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", params( "elevateIds", "1,5", @@ -1473,9 +1453,8 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[5]/str[@name='id'][.='3']" // group B ); assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", params( "elevateIds", "0,7", @@ -1491,9 +1470,8 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[5]/str[@name='id'][.='3']" // group B ); assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", params( "elevateIds", "6,0", @@ -1525,9 +1503,8 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[6]/str[@name='id'][.='0']" // null ); assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", params( "elevateIds", "1,5", @@ -1545,9 +1522,8 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[7]/str[@name='id'][.='0']" // null ); assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", params( "elevateIds", "0,7", @@ -1564,9 +1540,8 @@ public void testNullGroupNumericVsStringCollapse() { "//result/doc[6]/str[@name='id'][.='3']" // group B ); assertQ( - null, - "/elevate", - req( + reqWithPath( + "/elevate", params( "elevateIds", "6,0", 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 389447d20e4..e674c92eb41 100644 --- a/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java +++ b/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java @@ -493,9 +493,7 @@ public void testReRankQueries() { params.add("rows", "10"); params.add("elevateIds", "1"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=6]", "//result/doc[1]/str[@name='id'][.='1']", "//result/doc[2]/str[@name='id'][.='2']", @@ -557,9 +555,7 @@ public void testReRankQueries() { params.add("elevateIds", "1,4"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=6]", "//result/doc[1]/str[@name='id'][.='1']", // Elevated "//result/doc[2]/str[@name='id'][.='4']", // Elevated @@ -590,9 +586,7 @@ public void testReRankQueries() { params.add("elevateIds", "4,1"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=6]", "//result/doc[1]/str[@name='id'][.='4']", // Elevated "//result/doc[2]/str[@name='id'][.='1']", // Elevated @@ -622,9 +616,7 @@ public void testReRankQueries() { params.add("elevateIds", "4,1"); assertQ( - null, - "/elevate", - req(params), + reqWithPath("/elevate", params), "*[count(//doc)=6]", "//result/doc[1]/str[@name='id'][.='4']", // Elevated "//result/doc[2]/str[@name='id'][.='1']", // Elevated @@ -656,9 +648,7 @@ public void testReRankQueries() { params.add("elevateIds", "4,1"); assertQ( - null, - "/elevate", - 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 @@ -685,7 +675,7 @@ public void testReRankQueries() { params.add("rows", "10"); params.add("elevateIds", "4,1"); - assertQ(null, "/elevate", req(params), "*[count(//doc)=0]"); + assertQ(reqWithPath("/elevate", params), "*[count(//doc)=0]"); // Pass in reRankDocs lower than the length being collected. params = new ModifiableSolrParams(); @@ -1102,9 +1092,7 @@ public void testOverRank() { params.add("elevateIds", "1,4"); assertQ( - null, - "/elevate", - 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 323e392c0fc..71bfd564107 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -846,18 +846,19 @@ public static void assertQ(SolrQueryRequest req, String... tests) { assertQ(null, req, tests); } - /** 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 + * The handler that should process {@code req}: its {@link SolrQueryRequest#getPath()} if set, + * otherwise falls back to the deprecated "qt" request param. */ - public static void assertQ( - String message, String handler, SolrQueryRequest req, String... tests) { + private static String handlerOf(SolrQueryRequest req) { + String path = req.getPath(); + return path != null ? path : req.getParams().get(CommonParams.QT); + } + + /** Validates a query matches some XPath test expressions and closes the query */ + public static void assertQ(String message, SolrQueryRequest req, String... tests) { try { + String handler = handlerOf(req); String m = (null == message) ? "" : message + " "; // TODO log 'm' !!! // since the default (standard) response format is now JSON // need to explicitly request XML since this class uses XPath @@ -900,11 +901,7 @@ public static void assertQ( /** Makes a query request and returns the JSON string response */ public static String JQ(SolrQueryRequest req) throws Exception { - return JQ(req.getParams().get(CommonParams.QT), req); - } - - /** Makes a query request against the named handler and returns the JSON string response */ - public static String JQ(String handler, SolrQueryRequest req) throws Exception { + String handler = handlerOf(req); SolrParams params = req.getParams(); if (!"json".equals(params.get("wt", "xml")) || params.get("indent") == null) { ModifiableSolrParams newParams = new ModifiableSolrParams(params); @@ -953,19 +950,6 @@ public static String assertJQ(SolrQueryRequest req, String... tests) throws Exce return assertJQ(req, JSONTestUtil.DEFAULT_DELTA, tests); } - /** - * Validates a query against the named handler matches some JSON test expressions using the - * default double delta tolerance. - * - * @see JSONTestUtil#DEFAULT_DELTA - * @see #assertJQ(String,SolrQueryRequest,double,String...) - * @return The request response as a JSON String if all test patterns pass - */ - public static String assertJQ(String handler, SolrQueryRequest req, String... tests) - throws Exception { - return assertJQ(handler, req, JSONTestUtil.DEFAULT_DELTA, tests); - } - /** * Validates a query matches some JSON test expressions and closes the query. The text expression * is of the form path:JSON. The Noggit JSON parser used accepts single quoted strings and bare @@ -981,21 +965,7 @@ public static String assertJQ(String handler, SolrQueryRequest req, String... te */ public static String assertJQ(SolrQueryRequest req, double delta, String... tests) throws Exception { - return assertJQ(req.getParams().get(CommonParams.QT), req, delta, tests); - } - - /** - * Validates a query against the named handler matches some JSON test expressions and closes the - * query. - * - * @param handler the name of the request handler to process the request - * @param req Solr request to execute - * @param delta tolerance allowed in comparing float/double values - * @param tests JSON path expression + '==' + expected value - * @return The request response as a JSON String if all test patterns pass - */ - public static String assertJQ(String handler, SolrQueryRequest req, double delta, String... tests) - throws Exception { + String handler = handlerOf(req); SolrParams params = null; try { params = req.getParams(); @@ -1054,11 +1024,6 @@ public static String assertThatJQ(SolrQueryRequest req, Matcher test) thr return assertThatJQ(req, "", test); } - public static String assertThatJQ(String handler, SolrQueryRequest req, Matcher test) - throws Exception { - return assertThatJQ(handler, req, "", test); - } - /** * Validates a query completes and, using JSON deserialization, returns an object that passes the * given Matcher test. @@ -1071,24 +1036,10 @@ public static String assertThatJQ(String handler, SolrQueryRequest req, Matc * @param test Matcher for the given object returned from deserializing the response * @return The request response as a JSON String if the test matcher passes */ + @SuppressWarnings("unchecked") public static String assertThatJQ(SolrQueryRequest req, String message, Matcher test) throws Exception { - return assertThatJQ(req.getParams().get(CommonParams.QT), req, message, test); - } - - /** - * Validates a query against the named handler completes and, using JSON deserialization, returns - * an object that passes the given Matcher test. - * - * @param handler the name of the request handler to process the request - * @param req Solr request to execute - * @param message Failure message for test - * @param test Matcher for the given object returned from deserializing the response - * @return The request response as a JSON String if the test matcher passes - */ - @SuppressWarnings("unchecked") - public static String assertThatJQ( - String handler, SolrQueryRequest req, String message, Matcher test) throws Exception { + String handler = handlerOf(req); final SolrParams params = req.getParams(); try { if (!"json".equals(params.get("wt", "xml")) || params.get("indent") == null) { @@ -1129,14 +1080,9 @@ public static String assertThatJQ( /** Makes sure a query throws a SolrException with the listed response code */ public static void assertQEx(String message, SolrQueryRequest req, int code) { - assertQEx(message, req, code, req.getParams().get(CommonParams.QT)); - } - - /** Makes sure a query against the named handler throws a SolrException with the given code */ - public static void assertQEx(String message, SolrQueryRequest req, int code, String handler) { try { ignoreException("."); - h.query(handler, req); + h.query(handlerOf(req), req); fail(message); } catch (SolrException sex) { assertEquals(code, sex.code()); @@ -1147,16 +1093,11 @@ public static void assertQEx(String message, SolrQueryRequest req, int code, Str } } + /** Makes sure a query throws a SolrException with the listed response code */ public static void assertQEx(String message, SolrQueryRequest req, SolrException.ErrorCode code) { - assertQEx(message, req, code, req.getParams().get(CommonParams.QT)); - } - - /** Makes sure a query against the named handler throws a SolrException with the given code */ - public static void assertQEx( - String message, SolrQueryRequest req, SolrException.ErrorCode code, String handler) { try { ignoreException("."); - h.query(handler, req); + h.query(handlerOf(req), req); fail(message); } catch (SolrException e) { assertEquals(code.code, e.code()); @@ -1181,29 +1122,9 @@ public static void assertQEx( String exceptionMessage, SolrQueryRequest req, SolrException.ErrorCode code) { - assertQEx(failMessage, exceptionMessage, req, code, req.getParams().get(CommonParams.QT)); - } - - /** - * Makes sure a query against the named handler throws a SolrException with the listed response - * code and expected message - * - * @param failMessage The assert message to show when the query doesn't throw the expected - * exception - * @param exceptionMessage A substring of the message expected in the exception - * @param req Solr request - * @param code expected error code for the query - * @param handler the name of the request handler to process the request - */ - public static void assertQEx( - String failMessage, - String exceptionMessage, - SolrQueryRequest req, - SolrException.ErrorCode code, - String handler) { try { ignoreException("."); - h.query(handler, req); + h.query(handlerOf(req), req); fail(failMessage); } catch (SolrException e) { assertEquals(code.code, e.code()); @@ -1394,6 +1315,37 @@ public static SolrQueryRequest req(SolrParams params, String... moreParams) { return new SolrQueryRequestBase(h.getCore(), mp); } + /** + * Generates a SolrQueryRequest representing the specified path and query params + * + *

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 + * + *

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; From 75838e75bfe75abb35111ad450e47fe160c5a94c Mon Sep 17 00:00:00 2001 From: Jason Gerlowski Date: Sun, 9 Aug 2026 10:51:02 -0400 Subject: [PATCH 4/6] Replace qt usage in suggest+spellcheck tests Replaces a number of 'qt' usages with the new reqWithPath helper function, this time focusing mainly on suggest and spellcheck related tests in solr-core. --- .../component/InfixSuggestersTest.java | 26 ++-- .../component/SpellCheckComponentTest.java | 96 ++++++-------- ...uggestComponentContextFilterQueryTest.java | 60 ++++----- .../component/SuggestComponentTest.java | 121 ++++++------------ .../spelling/DirectSolrSpellCheckerTest.java | 5 +- .../solr/spelling/SpellCheckCollatorTest.java | 40 +++--- .../SpellCheckCollatorWithCollapseTest.java | 5 +- .../WordBreakSolrSpellCheckerTest.java | 40 +++--- .../solr/spelling/suggest/SuggesterTest.java | 12 +- .../suggest/TestAnalyzeInfixSuggestions.java | 35 ++--- .../suggest/TestAnalyzedSuggestions.java | 12 +- .../suggest/TestBlendedInfixSuggestions.java | 29 ++--- .../suggest/TestFileDictionaryLookup.java | 18 +-- .../suggest/TestFreeTextSuggestions.java | 14 +- .../suggest/TestFuzzyAnalyzedSuggestions.java | 28 ++-- .../TestHighFrequencyDictionaryFactory.java | 18 +-- .../suggest/TestPhraseSuggestions.java | 6 +- 17 files changed, 213 insertions(+), 352 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/handler/component/InfixSuggestersTest.java b/solr/core/src/test/org/apache/solr/handler/component/InfixSuggestersTest.java index db606921231..236504ba447 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/InfixSuggestersTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/InfixSuggestersTest.java @@ -45,7 +45,7 @@ public static void beforeClass() throws Exception { public void test2xBuildReload() throws Exception { for (int i = 0; i < 2; ++i) { assertQ( - req("qt", rh_analyzing_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), + reqWithPath(rh_analyzing_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), "//str[@name='command'][.='buildAll']"); h.reload(); } @@ -54,12 +54,12 @@ public void test2xBuildReload() throws Exception { @Test public void testTwoSuggestersBuildThenReload() throws Exception { assertQ( - req("qt", rh_analyzing_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), + reqWithPath(rh_analyzing_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), "//str[@name='command'][.='buildAll']"); h.reload(); assertQ( - req("qt", rh_blended_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), + reqWithPath(rh_blended_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), "//str[@name='command'][.='buildAll']"); h.reload(); } @@ -67,7 +67,7 @@ public void testTwoSuggestersBuildThenReload() throws Exception { @Test public void testBuildThen2xReload() throws Exception { assertQ( - req("qt", rh_analyzing_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), + reqWithPath(rh_analyzing_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), "//str[@name='command'][.='buildAll']"); h.reload(); h.reload(); @@ -76,7 +76,7 @@ public void testBuildThen2xReload() throws Exception { @Test public void testAnalyzingInfixSuggesterBuildThenReload() throws Exception { assertQ( - req("qt", rh_analyzing_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), + reqWithPath(rh_analyzing_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), "//str[@name='command'][.='buildAll']"); h.reload(); } @@ -84,7 +84,7 @@ public void testAnalyzingInfixSuggesterBuildThenReload() throws Exception { @Test public void testBlendedInfixSuggesterBuildThenReload() throws Exception { assertQ( - req("qt", rh_blended_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), + reqWithPath(rh_blended_short, SuggesterParams.SUGGEST_BUILD_ALL, "true"), "//str[@name='command'][.='buildAll']"); h.reload(); } @@ -102,11 +102,8 @@ public void testReloadDuringBuild() throws Exception { SolrCoreState.CoreIsClosedException.class, () -> assertQ( - req( - "qt", - rh_analyzing_long, - SuggesterParams.SUGGEST_BUILD_ALL, - "true"), + reqWithPath( + rh_analyzing_long, SuggesterParams.SUGGEST_BUILD_ALL, "true"), "//str[@name='command'][.='buildAll']"))); h.reload(); // Stop the dictionary's input iterator @@ -142,11 +139,8 @@ public void testShutdownDuringBuild() throws Exception { expected, () -> assertQ( - req( - "qt", - rh_analyzing_long, - SuggesterParams.SUGGEST_BUILD_ALL, - "true"), + reqWithPath( + rh_analyzing_long, SuggesterParams.SUGGEST_BUILD_ALL, "true"), "//str[@name='command'][.='buildAll']"))); Thread.sleep(100); // TODO: is there a better way to ensure that the build has begun? h.close(); diff --git a/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java index 3e4eb5e5095..660a059e380 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java @@ -78,8 +78,7 @@ public void tearDown() throws Exception { @Test public void testMaximumResultsForSuggest() throws Exception { assertJQ( - req( - "qt", + reqWithPath( rh, SpellCheckComponent.COMPONENT_NAME, "true", @@ -100,8 +99,7 @@ public void testMaximumResultsForSuggest() throws Exception { Exception.class, () -> { assertJQ( - req( - "qt", + reqWithPath( rh, SpellCheckComponent.COMPONENT_NAME, "true", @@ -119,8 +117,7 @@ public void testMaximumResultsForSuggest() throws Exception { }); assertJQ( - req( - "qt", + reqWithPath( rh, SpellCheckComponent.COMPONENT_NAME, "true", @@ -145,8 +142,7 @@ public void testMaximumResultsForSuggest() throws Exception { Exception.class, () -> { assertJQ( - req( - "qt", + reqWithPath( rh, SpellCheckComponent.COMPONENT_NAME, "true", @@ -168,8 +164,7 @@ public void testMaximumResultsForSuggest() throws Exception { }); assertJQ( - req( - "qt", + reqWithPath( rh, SpellCheckComponent.COMPONENT_NAME, "true", @@ -194,8 +189,7 @@ public void testMaximumResultsForSuggest() throws Exception { Exception.class, () -> { assertJQ( - req( - "qt", + reqWithPath( rh, SpellCheckComponent.COMPONENT_NAME, "true", @@ -220,8 +214,7 @@ public void testMaximumResultsForSuggest() throws Exception { @Test public void testExtendedResultsCount() throws Exception { assertJQ( - req( - "qt", + reqWithPath( rh, SpellCheckComponent.COMPONENT_NAME, "true", @@ -237,8 +230,7 @@ public void testExtendedResultsCount() throws Exception { "/spellcheck/suggestions/[1]/numFound==5"); assertJQ( - req( - "qt", + reqWithPath( rh, SpellCheckComponent.COMPONENT_NAME, "true", @@ -254,25 +246,24 @@ public void testExtendedResultsCount() throws Exception { @Test public void test() throws Exception { assertJQ( - req("qt", rh, SpellCheckComponent.COMPONENT_NAME, "true", "q", "documemt"), + reqWithPath(rh, SpellCheckComponent.COMPONENT_NAME, "true", "q", "documemt"), "/spellcheck=={'suggestions':['documemt',{'numFound':1,'startOffset':0,'endOffset':8,'suggestion':['document']}]}"); } @Test public void testNumericQuery() throws Exception { assertJQ( - req("qt", rh, SpellCheckComponent.COMPONENT_NAME, "true", "q", "12346"), + reqWithPath(rh, SpellCheckComponent.COMPONENT_NAME, "true", "q", "12346"), "/spellcheck=={'suggestions':['12346',{'numFound':1,'startOffset':0,'endOffset':5,'suggestion':['12345']}]}"); } @Test public void testPerDictionary() throws Exception { assertJQ( - req( + reqWithPath( + rh, "json.nl", "map", - "qt", - rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_BUILD, @@ -294,11 +285,10 @@ public void testInvalidDictionary() { assertQEx( "Invalid specified dictionary should throw exception", "Specified dictionaries do not exist: INVALID", - req( + reqWithPath( + rh, "json.nl", "map", - "qt", - rh, SpellCheckComponent.COMPONENT_NAME, "true", "q", @@ -310,11 +300,10 @@ public void testInvalidDictionary() { assertQEx( "Invalid specified dictionary should throw exception", "Specified dictionaries do not exist: INVALID2", - req( + reqWithPath( + rh, "json.nl", "map", - "qt", - rh, SpellCheckComponent.COMPONENT_NAME, "true", "q", @@ -329,11 +318,10 @@ public void testInvalidDictionary() { @Test public void testCollate() throws Exception { assertJQ( - req( + reqWithPath( + rh, "json.nl", "map", - "qt", - rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_BUILD, @@ -344,11 +332,10 @@ public void testCollate() throws Exception { "true"), "/spellcheck/collations/collation=='document'"); assertJQ( - req( + reqWithPath( + rh, "json.nl", "map", - "qt", - rh, SpellCheckComponent.COMPONENT_NAME, "true", "q", @@ -357,11 +344,10 @@ public void testCollate() throws Exception { "true"), "/spellcheck/collations/collation=='document lowerfilt:brown^4'"); assertJQ( - req( + reqWithPath( + rh, "json.nl", "map", - "qt", - rh, SpellCheckComponent.COMPONENT_NAME, "true", "q", @@ -370,11 +356,10 @@ public void testCollate() throws Exception { "true"), "/spellcheck/collations/collation=='document brown'"); assertJQ( - req( + reqWithPath( + rh, "json.nl", "map", - "qt", - rh, SpellCheckComponent.COMPONENT_NAME, "true", "q", @@ -415,8 +400,7 @@ public void testCollateExtendedResultsWithJsonNl() throws Exception { private void implTestCollateExtendedResultsWithJsonNl( String q, String jsonNl, boolean collateExtendedResults, String... tests) throws Exception { final SolrQueryRequest solrQueryRequest = - req( - CommonParams.QT, + reqWithPath( rh, CommonParams.Q, q, @@ -435,11 +419,10 @@ private void implTestCollateExtendedResultsWithJsonNl( public void testCorrectSpelling() throws Exception { // Make sure correct spellings are signaled in the response assertJQ( - req( + reqWithPath( + rh, "json.nl", "map", - "qt", - rh, SpellCheckComponent.COMPONENT_NAME, "true", "q", @@ -448,11 +431,10 @@ public void testCorrectSpelling() throws Exception { "true"), "/spellcheck/correctlySpelled==true"); assertJQ( - req( + reqWithPath( + rh, "json.nl", "map", - "qt", - rh, SpellCheckComponent.COMPONENT_NAME, "true", "spellcheck.dictionary", @@ -463,11 +445,10 @@ public void testCorrectSpelling() throws Exception { "true"), "/spellcheck/correctlySpelled==true"); assertJQ( - req( + reqWithPath( + rh, "json.nl", "map", - "qt", - rh, SpellCheckComponent.COMPONENT_NAME, "true", "spellcheck.dictionary", @@ -497,8 +478,7 @@ public void testReloadOnStart() throws Exception { assertU(adoc("id", "0", "lowerfilt", "This is a title")); assertU(commit()); SolrQueryRequest request = - req( - "qt", + reqWithPath( "/spellCheckCompRH", "q", "*:*", @@ -526,8 +506,6 @@ public void testReloadOnStart() throws Exception { request = req( - "qt", - "/spellCheckCompRH", "q", "*:*", "spellcheck.q", @@ -558,8 +536,8 @@ public void testReloadOnStart() throws Exception { @Test public void testRebuildOnCommit() throws Exception { SolrQueryRequest req = - req("q", "lowerfilt:lucenejavt", "qt", "/spellCheckCompRH", "spellcheck", "true"); - String response = h.query(req); + reqWithPath("/spellCheckCompRH", "q", "lowerfilt:lucenejavt", "spellcheck", "true"); + String response = h.query("/spellCheckCompRH", req); assertFalse("No suggestions should be returned", response.contains("lucenejava")); assertU(adoc("id", "11231", "lowerfilt", "lucenejava")); @@ -576,8 +554,7 @@ public void testThresholdTokenFrequency() throws Exception { // while "document" is present. assertJQ( - req( - "qt", + reqWithPath( rh, SpellCheckComponent.COMPONENT_NAME, "true", @@ -592,8 +569,7 @@ public void testThresholdTokenFrequency() throws Exception { "/spellcheck/suggestions/[1]/suggestion==[{'word':'document','freq':2}]"); assertJQ( - req( - "qt", + reqWithPath( rh, SpellCheckComponent.COMPONENT_NAME, "true", diff --git a/solr/core/src/test/org/apache/solr/handler/component/SuggestComponentContextFilterQueryTest.java b/solr/core/src/test/org/apache/solr/handler/component/SuggestComponentContextFilterQueryTest.java index 3d02dc6c395..64509d9d3cb 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/SuggestComponentContextFilterQueryTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/SuggestComponentContextFilterQueryTest.java @@ -108,8 +108,7 @@ public void setUp() throws Exception { @Test public void testContextFilterParamIsIgnoredWhenContextIsNotImplemented() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -128,8 +127,7 @@ public void testContextFilterParamIsIgnoredWhenContextIsNotImplemented() { @Test public void testContextFilteringIsIgnoredWhenContextIsImplementedButNotConfigured() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -150,9 +148,8 @@ public void testBuildThrowsIllegalArgumentExceptionWhenContextIsConfiguredButNot IllegalArgumentException.class, () -> { h.query( + rh, req( - "qt", - rh, SuggesterParams.SUGGEST_BUILD, "true", SuggesterParams.SUGGEST_DICT, @@ -164,8 +161,7 @@ public void testBuildThrowsIllegalArgumentExceptionWhenContextIsConfiguredButNot // When not building, no exception is thrown assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "false", @@ -179,15 +175,15 @@ public void testBuildThrowsIllegalArgumentExceptionWhenContextIsConfiguredButNot @Test public void testContextFilterIsTrimmed() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", SuggesterParams.SUGGEST_DICT, "suggest_blended_infix_suggester", SuggesterParams.SUGGEST_CONTEXT_FILTER_QUERY, - " ", // trimmed to null... just as if there was no context filter param + " ", + // trimmed to null... just as if there was no context filter param SuggesterParams.SUGGEST_Q, "examp"), "//lst[@name='suggest']/lst[@name='suggest_blended_infix_suggester']/lst[@name='examp']/int[@name='numFound'][.='3']"); @@ -195,8 +191,7 @@ public void testContextFilterIsTrimmed() { public void testExplicitFieldedQuery() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -213,8 +208,7 @@ public void testExplicitFieldedQuery() { public void testContextFilterOK() { // No filtering assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -229,8 +223,7 @@ public void testContextFilterOK() { // TermQuery assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -245,8 +238,7 @@ public void testContextFilterOK() { // OR BooleanQuery assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -262,8 +254,7 @@ public void testContextFilterOK() { // AND BooleanQuery assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -278,8 +269,7 @@ public void testContextFilterOK() { // PrefixQuery assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -294,8 +284,7 @@ public void testContextFilterOK() { // RangeQuery assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -311,8 +300,7 @@ public void testContextFilterOK() { // WildcardQuery assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -330,8 +318,7 @@ public void testContextFilterOK() { public void testStringContext() { // Here, the context field is a string, so it's case-sensitive assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -344,8 +331,7 @@ public void testStringContext() { "//lst[@name='suggest']/lst[@name='suggest_blended_infix_suggester_string']/lst[@name='examp']/int[@name='numFound'][.='0']"); assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -361,8 +347,7 @@ public void testStringContext() { @Test public void testContextFilterOnInvalidFieldGivesNoSuggestions() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", @@ -378,15 +363,15 @@ public void testContextFilterOnInvalidFieldGivesNoSuggestions() { @Test public void testContextFilterUsesAnalyzer() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", SuggesterParams.SUGGEST_DICT, "suggest_blended_infix_suggester", SuggesterParams.SUGGEST_CONTEXT_FILTER_QUERY, - "CTx1", // Will not match due to case + "CTx1", + // Will not match due to case SuggesterParams.SUGGEST_Q, "examp"), "//lst[@name='suggest']/lst[@name='suggest_blended_infix_suggester']/lst[@name='examp']/int[@name='numFound'][.='0']"); @@ -396,8 +381,7 @@ public void testContextFilterUsesAnalyzer() { @Test public void testContextFilterWithHighlight() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD, "true", diff --git a/solr/core/src/test/org/apache/solr/handler/component/SuggestComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/SuggestComponentTest.java index e805c96b6ef..6270a0abb4c 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/SuggestComponentTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/SuggestComponentTest.java @@ -60,15 +60,14 @@ public void tearDown() throws Exception { waitForWarming(); // rebuild suggesters with empty index assertQ( - req("qt", rh, SuggesterParams.SUGGEST_BUILD_ALL, "true"), + reqWithPath(rh, SuggesterParams.SUGGEST_BUILD_ALL, "true"), "//str[@name='command'][.='buildAll']"); } @Test public void testDocumentBased() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, "suggest_fuzzy_doc_dict", @@ -85,8 +84,7 @@ public void testDocumentBased() { "//lst[@name='suggest']/lst[@name='suggest_fuzzy_doc_dict']/lst[@name='exampel']/arr[@name='suggestions']/lst[2]/long[@name='weight'][.='40']"); assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, "suggest_fuzzy_doc_dict", @@ -106,8 +104,7 @@ public void testDocumentBased() { @Test public void testExpressionBased() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, "suggest_fuzzy_doc_expr_dict", @@ -127,8 +124,7 @@ public void testExpressionBased() { @Test public void testFileBased() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, "suggest_fuzzy_file_based", @@ -148,8 +144,7 @@ public void testFileBased() { @Test public void testMultiSuggester() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, "suggest_fuzzy_doc_dict", @@ -176,8 +171,7 @@ public void testMultiSuggester() { @Test public void testBuildAllSuggester() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_BUILD_ALL, "true", @@ -188,15 +182,14 @@ public void testBuildAllSuggester() { "//str[@name='command'][.='buildAll']"); assertQ( - req("qt", rh, SuggesterParams.SUGGEST_BUILD_ALL, "true"), + reqWithPath(rh, SuggesterParams.SUGGEST_BUILD_ALL, "true"), "//str[@name='command'][.='buildAll']"); } @Test public void testReloadAllSuggester() { assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_RELOAD_ALL, "true", @@ -207,7 +200,7 @@ public void testReloadAllSuggester() { "//str[@name='command'][.='reloadAll']"); assertQ( - req("qt", rh, SuggesterParams.SUGGEST_RELOAD_ALL, "true"), + reqWithPath(rh, SuggesterParams.SUGGEST_RELOAD_ALL, "true"), "//str[@name='command'][.='reloadAll']"); } @@ -216,8 +209,7 @@ public void testBadSuggesterName() { String fakeSuggesterName = "does-not-exist"; assertQEx( "No suggester named " + fakeSuggesterName + " was configured", - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, fakeSuggesterName, @@ -231,7 +223,7 @@ public void testBadSuggesterName() { "'" + SuggesterParams.SUGGEST_DICT + "' parameter not specified and no default suggester configured", - req("qt", rh, SuggesterParams.SUGGEST_Q, "exampel", SuggesterParams.SUGGEST_COUNT, "5"), + reqWithPath(rh, SuggesterParams.SUGGEST_Q, "exampel", SuggesterParams.SUGGEST_COUNT, "5"), SolrException.ErrorCode.BAD_REQUEST); } @@ -281,8 +273,7 @@ public void testDefaultBuildOnStartupNotStoredDict() throws Exception { // Validate that the suggester was built on new/reload core assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -302,8 +293,7 @@ public void testDefaultBuildOnStartupNotStoredDict() throws Exception { // buildOnCommit=false, this doc should not be in the suggester yet assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -318,8 +308,7 @@ public void testDefaultBuildOnStartupNotStoredDict() throws Exception { reloadCore(random().nextBoolean()); assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -377,8 +366,7 @@ public void testDefaultBuildOnStartupStoredDict() throws Exception { .txt()); assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -392,18 +380,12 @@ public void testDefaultBuildOnStartupStoredDict() throws Exception { // build the suggester manually assertQ( - req( - "qt", - rh, - SuggesterParams.SUGGEST_DICT, - suggester, - SuggesterParams.SUGGEST_BUILD, - "true"), + reqWithPath( + rh, SuggesterParams.SUGGEST_DICT, suggester, SuggesterParams.SUGGEST_BUILD, "true"), "//str[@name='command'][.='build']"); assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -419,8 +401,7 @@ public void testDefaultBuildOnStartupStoredDict() throws Exception { // Validate that the suggester was loaded on new/reload core assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -440,8 +421,7 @@ public void testDefaultBuildOnStartupStoredDict() throws Exception { waitForWarming(); // buildOnCommit=false, this doc should not be in the suggester yet assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -456,8 +436,7 @@ public void testDefaultBuildOnStartupStoredDict() throws Exception { reloadCore(random().nextBoolean()); assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -471,18 +450,12 @@ public void testDefaultBuildOnStartupStoredDict() throws Exception { // build the suggester manually assertQ( - req( - "qt", - rh, - SuggesterParams.SUGGEST_DICT, - suggester, - SuggesterParams.SUGGEST_BUILD, - "true"), + reqWithPath( + rh, SuggesterParams.SUGGEST_DICT, suggester, SuggesterParams.SUGGEST_BUILD, "true"), "//str[@name='command'][.='build']"); assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -541,18 +514,12 @@ public void testLoadOnStartup() throws Exception { // build the suggester manually assertQ( - req( - "qt", - rh, - SuggesterParams.SUGGEST_DICT, - suggester, - SuggesterParams.SUGGEST_BUILD, - "true"), + reqWithPath( + rh, SuggesterParams.SUGGEST_DICT, suggester, SuggesterParams.SUGGEST_BUILD, "true"), "//str[@name='command'][.='build']"); assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -568,8 +535,7 @@ public void testLoadOnStartup() throws Exception { // Validate that the suggester was loaded on core reload assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -585,8 +551,7 @@ public void testLoadOnStartup() throws Exception { // Validate that the suggester was loaded on new core assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggester, @@ -654,8 +619,7 @@ private void doTestBuildOnStartup(boolean createNewCores) throws Exception { // verify that this suggester is built (there was a commit in setUp) assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggesterFuzzy, @@ -676,8 +640,7 @@ private void doTestBuildOnStartup(boolean createNewCores) throws Exception { // The suggester should be empty assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggesterFuzzy, @@ -691,8 +654,7 @@ private void doTestBuildOnStartup(boolean createNewCores) throws Exception { // build the suggester manually assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggesterFuzzy, @@ -702,8 +664,7 @@ private void doTestBuildOnStartup(boolean createNewCores) throws Exception { // validate the suggester is built again assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggesterFuzzy, @@ -755,8 +716,7 @@ private void doTestBuildOnStartup(boolean createNewCores) throws Exception { reloadCore(createNewCores); // verify that this suggester is built (should build on startup) assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggestStartup, @@ -776,8 +736,7 @@ private void doTestBuildOnStartup(boolean createNewCores) throws Exception { waitForWarming(); assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggestStartup, @@ -791,8 +750,7 @@ private void doTestBuildOnStartup(boolean createNewCores) throws Exception { // build the suggester manually assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggestStartup, @@ -801,8 +759,7 @@ private void doTestBuildOnStartup(boolean createNewCores) throws Exception { "//str[@name='command'][.='build']"); assertQ( - req( - "qt", + reqWithPath( rh, SuggesterParams.SUGGEST_DICT, suggestStartup, @@ -830,6 +787,6 @@ private void reloadCore(boolean createNewCore) throws Exception { waitForWarming(); } - assertQ(req("qt", "/select", "q", "*:*"), "//*[@numFound='11']"); + assertQ(reqWithPath("/select", "q", "*:*"), "//*[@numFound='11']"); } } diff --git a/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java b/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java index 9091f650184..3a642df514f 100644 --- a/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java +++ b/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java @@ -102,11 +102,10 @@ public void test() throws Exception { @Test public void testOnlyMorePopularWithExtendedResults() { assertQ( - req( + reqWithPath( + "/spellCheckCompRH", "q", "teststop:fox", - "qt", - "/spellCheckCompRH", SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_DICT, diff --git a/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java b/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java index 382ed633370..678ff73d848 100644 --- a/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java +++ b/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java @@ -219,7 +219,8 @@ public void testCollationWithHypens() { public void testCollateWithOverride() { assertQ( - req( + reqWithPath( + "/spellCheckCompRH", SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_DICT, @@ -232,8 +233,6 @@ public void testCollateWithOverride() { "10", SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10", - "qt", - "/spellCheckCompRH", "defType", "edismax", "qf", @@ -244,7 +243,8 @@ public void testCollateWithOverride() { "partisian politcal mashine"), "//lst[@name='spellcheck']/lst[@name='collations']/str[@name='collation']='parisian political machine'"); assertQ( - req( + reqWithPath( + "/spellCheckCompRH", SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_DICT, @@ -257,8 +257,6 @@ public void testCollateWithOverride() { "10", SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10", - "qt", - "/spellCheckCompRH", "defType", "edismax", "qf", @@ -504,11 +502,10 @@ public void testContextSensitiveCollate() { String[] dictionary = {"direct", "default_teststop"}; for (int i = 0; i <= 1; i++) { assertQ( - req( + reqWithPath( + "/spellCheckCompRH", "q", "teststop:(flew AND form AND heathrow)", - "qt", - "/spellCheckCompRH", "indent", "true", SpellCheckComponent.COMPONENT_NAME, @@ -544,11 +541,10 @@ public void testContextSensitiveCollate() { "//lst[@name='spellcheck']/lst[@name='collations']/lst[@name='collation']/lst[@name='misspellingsAndCorrections']/str[@name='form']='from'"); assertQ( - req( + reqWithPath( + "/spellCheckCompRH", "q", "teststop:(june AND customs)", - "qt", - "/spellCheckCompRH", "indent", "true", SpellCheckComponent.COMPONENT_NAME, @@ -579,13 +575,12 @@ public void testContextSensitiveCollate() { "//lst[@name='spellcheck']/lst[@name='collations']/lst[@name='collation']/lst[@name='misspellingsAndCorrections']/str[@name='june']='jane'"); // SOLR-5090, alternativeTermCount==0 was being evaluated, would sometimes throw NPE assertQ( - req( + reqWithPath( + "/spellCheckCompRH", "q", "teststop:(june customs)", "mm", "2", - "qt", - "/spellCheckCompRH", "indent", "true", SpellCheckComponent.COMPONENT_NAME, @@ -620,13 +615,11 @@ public void testEstimatedHitCounts() { SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1", SpellingParams.SPELLCHECK_COLLATE_EXTENDED_RESULTS, - "true", - "qt", - "/spellCheckCompRH"); + "true"); // default case, no SPELLCHECK_COLLATE_MAX_COLLECT_DOCS should be exact num hits assertQ( - req(reusedParams, CommonParams.Q, "teststop:metnoia"), + reqWithPath("/spellCheckCompRH", reusedParams, CommonParams.Q, "teststop:metnoia"), xpathPrefix + "str[@name='collationQuery']='teststop:metanoia'", xpathPrefix + "long[@name='hits']=6"); @@ -635,7 +628,8 @@ public void testEstimatedHitCounts() { // "estimating" and getting exact number as well. for (String val : new String[] {"0", "30", "100", "10000"}) { assertQ( - req( + reqWithPath( + "/spellCheckCompRH", reusedParams, CommonParams.Q, "teststop:metnoia", @@ -651,7 +645,8 @@ public void testEstimatedHitCounts() { for (int iter = 0; iter < iters; iter++) { final int val = TestUtil.nextInt(random(), 1, 17); assertQ( - req( + reqWithPath( + "/spellCheckCompRH", reusedParams, CommonParams.Q, "teststop:metnoia", @@ -687,7 +682,8 @@ public void testEstimatedHitCounts() { hitsXPath += "[.=" + NUM_DOCS_WITH_TERM_EVERYOTHER + "]"; } assertQ( - req( + reqWithPath( + "/spellCheckCompRH", reusedParams, CommonParams.Q, "teststop:everother", diff --git a/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorWithCollapseTest.java b/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorWithCollapseTest.java index 2a36cb7d951..80716aaa64b 100644 --- a/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorWithCollapseTest.java +++ b/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorWithCollapseTest.java @@ -62,7 +62,8 @@ public void test() { params(CommonParams.FQ, "{!collapse tag=collapser field=group_i}") }) { assertQ( - req( + reqWithPath( + "/spellCheckCompRH_Direct", params, SpellCheckComponent.COMPONENT_NAME, "true", @@ -78,8 +79,6 @@ public void test() { "1", CommonParams.Q, "a_s:lpve", - CommonParams.QT, - "/spellCheckCompRH_Direct", SpellingParams.SPELLCHECK_COLLATE_MAX_COLLECT_DOCS, "5", "expand", diff --git a/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java b/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java index 59d906dc257..87db8f6176a 100644 --- a/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java +++ b/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java @@ -160,11 +160,10 @@ public void testStandAlone() throws Exception { @Test public void testInConjunction() { assertQ( - req( + reqWithPath( + "/spellCheckWithWordbreak", "q", "lowerfilt:(paintable pine apple good ness)", - "qt", - "/spellCheckWithWordbreak", "indent", "true", SpellCheckComponent.SPELLCHECK_BUILD, @@ -232,11 +231,10 @@ public void testInConjunction() { @Test public void testCollate() { assertQ( - req( + reqWithPath( + "/spellCheckWithWordbreak", "q", "lowerfilt:(paintable pine apple godness)", - "qt", - "/spellCheckWithWordbreak", "indent", "true", SpellCheckComponent.SPELLCHECK_BUILD, @@ -268,11 +266,10 @@ public void testCollate() { "//lst[@name='collation'][10]/lst[@name='misspellingsAndCorrections']/str[@name='apple']='ample'", "//lst[@name='collation'][10]/lst[@name='misspellingsAndCorrections']/str[@name='godness']='goodness'"); assertQ( - req( + reqWithPath( + "/spellCheckWithWordbreak", "q", "lowerfilt:(pine AND apple)", - "qt", - "/spellCheckWithWordbreak", "indent", "true", SpellCheckComponent.COMPONENT_NAME, @@ -291,11 +288,10 @@ public void testCollate() { "//lst[@name='collation'][2 ]/str[@name='collationQuery']='lowerfilt:(pineapple)'", "//lst[@name='collation'][3 ]/str[@name='collationQuery']='lowerfilt:((pi AND ne) AND ample)'"); assertQ( - req( + reqWithPath( + "/spellCheckWithWordbreak", "q", "lowerfilt:pine AND NOT lowerfilt:apple", - "qt", - "/spellCheckWithWordbreak", "indent", "true", SpellCheckComponent.COMPONENT_NAME, @@ -313,11 +309,10 @@ public void testCollate() { "//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:line AND NOT lowerfilt:ample'", "//lst[@name='collation'][2 ]/str[@name='collationQuery']='lowerfilt:(pi AND ne) AND NOT lowerfilt:ample'"); assertQ( - req( + reqWithPath( + "/spellCheckWithWordbreak", "q", "lowerfilt:pine NOT lowerfilt:apple", - "qt", - "/spellCheckWithWordbreak", "indent", "true", SpellCheckComponent.COMPONENT_NAME, @@ -335,11 +330,10 @@ public void testCollate() { "//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:line NOT lowerfilt:ample'", "//lst[@name='collation'][2 ]/str[@name='collationQuery']='lowerfilt:(pi AND ne) NOT lowerfilt:ample'"); assertQ( - req( + reqWithPath( + "/spellCheckWithWordbreak", "q", "lowerfilt:(+pine -apple)", - "qt", - "/spellCheckWithWordbreak", "indent", "true", SpellCheckComponent.COMPONENT_NAME, @@ -357,11 +351,10 @@ public void testCollate() { "//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:(+line -ample)'", "//lst[@name='collation'][2 ]/str[@name='collationQuery']='lowerfilt:(+pi +ne -ample)'"); assertQ( - req( + reqWithPath( + "/spellCheckWithWordbreak", "q", "lowerfilt:(+printableinpuntableplantable)", - "qt", - "/spellCheckWithWordbreak", "indent", "true", SpellCheckComponent.COMPONENT_NAME, @@ -378,11 +371,10 @@ public void testCollate() { "1"), "//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:(+printable +in +puntable +plantable)'"); assertQ( - req( + reqWithPath( + "/spellCheckWithWordbreak", "q", "zxcv AND qwtp AND fghj", - "qt", - "/spellCheckWithWordbreak", "defType", "edismax", "qf", diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java b/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java index 78984412cab..314d245fbeb 100644 --- a/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java +++ b/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java @@ -52,8 +52,7 @@ public void testSuggestions() { assertU(commit()); // configured to do a rebuild on commit assertQ( - req( - "qt", + reqWithPath( requestUri, "q", "ac", @@ -76,8 +75,7 @@ public void testReload() throws Exception { waitForWarming(); assertQ( - req( - "qt", + reqWithPath( requestUri, "q", "ac", @@ -95,8 +93,7 @@ public void testRebuild() { addDocs(); assertU(commit()); assertQ( - req( - "qt", + reqWithPath( requestUri, "q", "ac", @@ -108,8 +105,7 @@ public void testRebuild() { assertU(adoc("id", "4", "text", "actually")); assertU(commit()); assertQ( - req( - "qt", + reqWithPath( requestUri, "q", "ac", diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/TestAnalyzeInfixSuggestions.java b/solr/core/src/test/org/apache/solr/spelling/suggest/TestAnalyzeInfixSuggestions.java index 3224f9b8894..0217b63ddfb 100644 --- a/solr/core/src/test/org/apache/solr/spelling/suggest/TestAnalyzeInfixSuggestions.java +++ b/solr/core/src/test/org/apache/solr/spelling/suggest/TestAnalyzeInfixSuggestions.java @@ -27,26 +27,25 @@ public class TestAnalyzeInfixSuggestions extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-phrasesuggest.xml", "schema-phrasesuggest.xml"); - assertQ(req("qt", URI_DEFAULT, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); - assertQ(req("qt", URI_SUGGEST_DEFAULT, "q", "", SuggesterParams.SUGGEST_BUILD_ALL, "true")); + assertQ(reqWithPath(URI_DEFAULT, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); + assertQ(reqWithPath(URI_SUGGEST_DEFAULT, "q", "", SuggesterParams.SUGGEST_BUILD_ALL, "true")); } public void testSingle() { assertQ( - req("qt", URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "1"), + reqWithPath(URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[1][.='Japanese Autocomplete and Japanese Highlighter broken']"); assertQ( - req("qt", URI_DEFAULT, "q", "high", SpellingParams.SPELLCHECK_COUNT, "1"), + reqWithPath(URI_DEFAULT, "q", "high", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='high']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='high']/arr[@name='suggestion']/str[1][.='Japanese Autocomplete and Japanese Highlighter broken']"); /* equivalent SolrSuggester, SuggestComponent tests */ assertQ( - req( - "qt", + reqWithPath( URI_SUGGEST_DEFAULT, "q", "japan", @@ -58,8 +57,7 @@ public void testSingle() { "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='japan']/arr[@name='suggestions']/lst[1]/str[@name='term'][.='Japanese Autocomplete and Japanese Highlighter broken']"); assertQ( - req( - "qt", + reqWithPath( URI_SUGGEST_DEFAULT, "q", "high", @@ -74,18 +72,18 @@ public void testSingle() { public void testMultiple() { assertQ( - req("qt", URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "2"), + reqWithPath(URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "2"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/int[@name='numFound'][.='2']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[1][.='Japanese Autocomplete and Japanese Highlighter broken']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[2][.='Add Japanese Kanji number normalization to Kuromoji']"); assertQ( - req("qt", URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[1][.='Japanese Autocomplete and Japanese Highlighter broken']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[2][.='Add Japanese Kanji number normalization to Kuromoji']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[3][.='Add decompose compound Japanese Katakana token capability to Kuromoji']"); assertQ( - req("qt", URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "4"), + reqWithPath(URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "4"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[1][.='Japanese Autocomplete and Japanese Highlighter broken']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[2][.='Add Japanese Kanji number normalization to Kuromoji']", @@ -93,8 +91,7 @@ public void testMultiple() { /* SolrSuggester, SuggestComponent tests: allTermsRequire (true), highlight (true) */ assertQ( - req( - "qt", + reqWithPath( URI_SUGGEST_DEFAULT, "q", "japan", @@ -107,8 +104,7 @@ public void testMultiple() { "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='japan']/arr[@name='suggestions']/lst[2]/str[@name='term'][.='Add Japanese Kanji number normalization to Kuromoji']"); assertQ( - req( - "qt", + reqWithPath( URI_SUGGEST_DEFAULT, "q", "japanese ka", @@ -123,8 +119,7 @@ public void testMultiple() { public void testWithoutHighlight() { assertQ( - req( - "qt", + reqWithPath( URI_SUGGEST_DEFAULT, "q", "japan", @@ -139,8 +134,7 @@ public void testWithoutHighlight() { public void testNotAllTermsRequired() { assertQ( - req( - "qt", + reqWithPath( URI_SUGGEST_DEFAULT, "q", "japanese javanese", @@ -154,8 +148,7 @@ public void testNotAllTermsRequired() { "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_not_all_terms_required']/lst[@name='japanese javanese']/arr[@name='suggestions']/lst[3]/str[@name='term'][.='Add decompose compound Japanese Katakana token capability to Kuromoji']"); assertQ( - req( - "qt", + reqWithPath( URI_SUGGEST_DEFAULT, "q", "just number", diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/TestAnalyzedSuggestions.java b/solr/core/src/test/org/apache/solr/spelling/suggest/TestAnalyzedSuggestions.java index 41079727ef7..71d0fde39a7 100644 --- a/solr/core/src/test/org/apache/solr/spelling/suggest/TestAnalyzedSuggestions.java +++ b/solr/core/src/test/org/apache/solr/spelling/suggest/TestAnalyzedSuggestions.java @@ -26,31 +26,31 @@ public class TestAnalyzedSuggestions extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-phrasesuggest.xml", "schema-phrasesuggest.xml"); - assertQ(req("qt", URI, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); + assertQ(reqWithPath(URI, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); } public void test() { assertQ( - req("qt", URI, "q", "hokk", SpellingParams.SPELLCHECK_COUNT, "1"), + reqWithPath(URI, "q", "hokk", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='hokk']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='hokk']/arr[@name='suggestion']/str[1][.='北海道']"); assertQ( - req("qt", URI, "q", "ほっk", SpellingParams.SPELLCHECK_COUNT, "1"), + reqWithPath(URI, "q", "ほっk", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ほっk']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ほっk']/arr[@name='suggestion']/str[1][.='北海道']"); assertQ( - req("qt", URI, "q", "ホッk", SpellingParams.SPELLCHECK_COUNT, "1"), + reqWithPath(URI, "q", "ホッk", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ホッk']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ホッk']/arr[@name='suggestion']/str[1][.='北海道']"); assertQ( - req("qt", URI, "q", "ホッk", SpellingParams.SPELLCHECK_COUNT, "1"), + reqWithPath(URI, "q", "ホッk", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ホッk']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ホッk']/arr[@name='suggestion']/str[1][.='北海道']"); } public void testMultiple() { assertQ( - req("qt", URI, "q", "h", SpellingParams.SPELLCHECK_COUNT, "2"), + reqWithPath(URI, "q", "h", SpellingParams.SPELLCHECK_COUNT, "2"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='h']/int[@name='numFound'][.='2']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='h']/arr[@name='suggestion']/str[1][.='話した']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='h']/arr[@name='suggestion']/str[2][.='北海道']"); diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/TestBlendedInfixSuggestions.java b/solr/core/src/test/org/apache/solr/spelling/suggest/TestBlendedInfixSuggestions.java index 2157efd2822..ed798be1017 100644 --- a/solr/core/src/test/org/apache/solr/spelling/suggest/TestBlendedInfixSuggestions.java +++ b/solr/core/src/test/org/apache/solr/spelling/suggest/TestBlendedInfixSuggestions.java @@ -25,13 +25,12 @@ public class TestBlendedInfixSuggestions extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-phrasesuggest.xml", "schema-phrasesuggest.xml"); - assertQ(req("qt", URI, "q", "", SuggesterParams.SUGGEST_BUILD_ALL, "true")); + assertQ(reqWithPath(URI, "q", "", SuggesterParams.SUGGEST_BUILD_ALL, "true")); } public void testLinearBlenderType() { assertQ( - req( - "qt", + reqWithPath( URI, "q", "the", @@ -53,8 +52,7 @@ public void testLinearBlenderType() { public void testReciprocalBlenderType() { assertQ( - req( - "qt", + reqWithPath( URI, "q", "the", @@ -78,8 +76,7 @@ public void testReciprocalBlenderType() { testExponentialReciprocalBlenderTypeExponent1() { // exponent=1 will give same output as // reciprocal assertQ( - req( - "qt", + reqWithPath( URI, "q", "the", @@ -101,8 +98,7 @@ public void testReciprocalBlenderType() { public void testExponentialReciprocalBlenderType() { // default is exponent=2.0 assertQ( - req( - "qt", + reqWithPath( URI, "q", "the", @@ -124,8 +120,7 @@ public void testExponentialReciprocalBlenderType() { // default is exponent=2.0 public void testMultiSuggester() { assertQ( - req( - "qt", + reqWithPath( URI, "q", "the", @@ -160,8 +155,7 @@ public void testMultiSuggester() { public void testSuggestCount() { assertQ( - req( - "qt", + reqWithPath( URI, "q", "the", @@ -172,8 +166,7 @@ public void testSuggestCount() { "//lst[@name='suggest']/lst[@name='blended_infix_suggest_reciprocal']/lst[@name='the']/int[@name='numFound'][.='1']"); assertQ( - req( - "qt", + reqWithPath( URI, "q", "the", @@ -184,8 +177,7 @@ public void testSuggestCount() { "//lst[@name='suggest']/lst[@name='blended_infix_suggest_reciprocal']/lst[@name='the']/int[@name='numFound'][.='2']"); assertQ( - req( - "qt", + reqWithPath( URI, "q", "the", @@ -196,8 +188,7 @@ public void testSuggestCount() { "//lst[@name='suggest']/lst[@name='blended_infix_suggest_reciprocal']/lst[@name='the']/int[@name='numFound'][.='3']"); assertQ( - req( - "qt", + reqWithPath( URI, "q", "the", diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/TestFileDictionaryLookup.java b/solr/core/src/test/org/apache/solr/spelling/suggest/TestFileDictionaryLookup.java index 093a0c06b59..2d9abe63e27 100644 --- a/solr/core/src/test/org/apache/solr/spelling/suggest/TestFileDictionaryLookup.java +++ b/solr/core/src/test/org/apache/solr/spelling/suggest/TestFileDictionaryLookup.java @@ -27,8 +27,7 @@ public class TestFileDictionaryLookup extends SolrTestCaseJ4 { public static void beforeClass() throws Exception { initCore("solrconfig-phrasesuggest.xml", "schema-phrasesuggest.xml"); assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "", @@ -42,8 +41,7 @@ public void testDefault() { // tests to demonstrate default maxEdit parameter (value: 1), control for testWithMaxEdit2 assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "chagn", @@ -62,8 +60,7 @@ public void testDefault() { + "']/lst[@name='chagn']/arr[@name='suggestions']/lst[2]/str[@name='term'][.='change']"); assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "chacn", @@ -82,8 +79,7 @@ public void testDefault() { + "']/lst[@name='chacn']/arr[@name='suggestions']/lst[2]/str[@name='term'][.='change']"); assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "chagr", @@ -99,8 +95,7 @@ public void testDefault() { + "']/lst[@name='chagr']/arr[@name='suggestions']/lst[1]/str[@name='term'][.='charge']"); assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "chanr", @@ -113,8 +108,7 @@ public void testDefault() { + "']/lst[@name='chanr']/int[@name='numFound'][.='3']"); assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "cyhnce", diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/TestFreeTextSuggestions.java b/solr/core/src/test/org/apache/solr/spelling/suggest/TestFreeTextSuggestions.java index 3bfa6130f38..c778e26492f 100644 --- a/solr/core/src/test/org/apache/solr/spelling/suggest/TestFreeTextSuggestions.java +++ b/solr/core/src/test/org/apache/solr/spelling/suggest/TestFreeTextSuggestions.java @@ -25,13 +25,12 @@ public class TestFreeTextSuggestions extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-phrasesuggest.xml", "schema-phrasesuggest.xml"); - assertQ(req("qt", URI, "q", "", SuggesterParams.SUGGEST_BUILD_ALL, "true")); + assertQ(reqWithPath(URI, "q", "", SuggesterParams.SUGGEST_BUILD_ALL, "true")); } public void test() { assertQ( - req( - "qt", + reqWithPath( URI, "q", "foo b", @@ -43,8 +42,7 @@ public void test() { "//lst[@name='suggest']/lst[@name='free_text_suggest']/lst[@name='foo b']/arr[@name='suggestions']/lst[1]/str[@name='term'][.='foo bar']"); assertQ( - req( - "qt", + reqWithPath( URI, "q", "foo ", @@ -57,8 +55,7 @@ public void test() { "//lst[@name='suggest']/lst[@name='free_text_suggest']/lst[@name='foo ']/arr[@name='suggestions']/lst[2]/str[@name='term'][.='foo bee']"); assertQ( - req( - "qt", + reqWithPath( URI, "q", "foo", @@ -69,8 +66,7 @@ public void test() { "//lst[@name='suggest']/lst[@name='free_text_suggest']/lst[@name='foo']/int[@name='numFound'][.='1']", "//lst[@name='suggest']/lst[@name='free_text_suggest']/lst[@name='foo']/arr[@name='suggestions']/lst[1]/str[@name='term'][.='foo']"); assertQ( - req( - "qt", + reqWithPath( URI, "q", "b", diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/TestFuzzyAnalyzedSuggestions.java b/solr/core/src/test/org/apache/solr/spelling/suggest/TestFuzzyAnalyzedSuggestions.java index bed48660a55..f2782940a40 100644 --- a/solr/core/src/test/org/apache/solr/spelling/suggest/TestFuzzyAnalyzedSuggestions.java +++ b/solr/core/src/test/org/apache/solr/spelling/suggest/TestFuzzyAnalyzedSuggestions.java @@ -30,63 +30,63 @@ public class TestFuzzyAnalyzedSuggestions extends SolrTestCaseJ4 { public static void beforeClass() throws Exception { initCore("solrconfig-phrasesuggest.xml", "schema-phrasesuggest.xml"); // Suggestions text include : change, charge, chance - assertQ(req("qt", URI_DEFAULT, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); - assertQ(req("qt", URI_MIN_EDIT_2, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); - assertQ(req("qt", URI_NON_PREFIX_LENGTH_4, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); - assertQ(req("qt", URI_MIN_FUZZY_LENGTH, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); + assertQ(reqWithPath(URI_DEFAULT, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); + assertQ(reqWithPath(URI_MIN_EDIT_2, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); + assertQ(reqWithPath(URI_NON_PREFIX_LENGTH_4, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); + assertQ(reqWithPath(URI_MIN_FUZZY_LENGTH, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); } public void testDefault() { // tests to demonstrate default maxEdit parameter (value: 1), control for testWithMaxEdit2 assertQ( - req("qt", URI_DEFAULT, "q", "chagn", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_DEFAULT, "q", "chagn", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/int[@name='numFound'][.='2']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/arr[@name='suggestion']/str[1][.='chance']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/arr[@name='suggestion']/str[2][.='change']"); assertQ( - req("qt", URI_DEFAULT, "q", "chacn", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_DEFAULT, "q", "chacn", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chacn']/int[@name='numFound'][.='2']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chacn']/arr[@name='suggestion']/str[1][.='chance']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chacn']/arr[@name='suggestion']/str[2][.='change']"); assertQ( - req("qt", URI_DEFAULT, "q", "chagr", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_DEFAULT, "q", "chagr", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagr']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagr']/arr[@name='suggestion']/str[1][.='charge']"); // test to demonstrate default nonFuzzyPrefix parameter (value: 1), control for // testWithNonFuzzyPrefix4 assertQ( - req("qt", URI_DEFAULT, "q", "chanr", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_DEFAULT, "q", "chanr", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chanr']/int[@name='numFound'][.='3']"); // test to demonstrate default minFuzzyPrefix parameter (value: 3), control for // testWithMinFuzzyLength2 assertQ( - req("qt", URI_DEFAULT, "q", "cyhnce", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_DEFAULT, "q", "cyhnce", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions'][not(node())]"); } public void testWithMaxEdit2() { assertQ( - req("qt", URI_MIN_EDIT_2, "q", "chagn", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_MIN_EDIT_2, "q", "chagn", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/arr[@name='suggestion']/str[1][.='chance']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/arr[@name='suggestion']/str[2][.='change']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/arr[@name='suggestion']/str[3][.='charge']"); assertQ( - req("qt", URI_MIN_EDIT_2, "q", "chagr", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_MIN_EDIT_2, "q", "chagr", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagr']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagr']/arr[@name='suggestion']/str[1][.='chance']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagr']/arr[@name='suggestion']/str[2][.='change']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagr']/arr[@name='suggestion']/str[3][.='charge']"); assertQ( - req("qt", URI_MIN_EDIT_2, "q", "chacn", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_MIN_EDIT_2, "q", "chacn", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chacn']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chacn']/arr[@name='suggestion']/str[1][.='chance']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chacn']/arr[@name='suggestion']/str[2][.='change']", @@ -97,7 +97,7 @@ public void testWithNonFuzzyPrefix4() { // This test should not match charge, as the nonFuzzyPrefix has been set to 4 assertQ( - req("qt", URI_NON_PREFIX_LENGTH_4, "q", "chanr", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_NON_PREFIX_LENGTH_4, "q", "chanr", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chanr']/int[@name='numFound'][.='2']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chanr']/arr[@name='suggestion']/str[1][.='chance']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chanr']/arr[@name='suggestion']/str[2][.='change']"); @@ -107,7 +107,7 @@ public void testWithMinFuzzyLength2() { // This test should match chance as the minFuzzyLength parameter has been set to 2 assertQ( - req("qt", URI_MIN_FUZZY_LENGTH, "q", "chynce", SpellingParams.SPELLCHECK_COUNT, "3"), + reqWithPath(URI_MIN_FUZZY_LENGTH, "q", "chynce", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chynce']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chynce']/arr[@name='suggestion']/str[1][.='chance']"); } diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/TestHighFrequencyDictionaryFactory.java b/solr/core/src/test/org/apache/solr/spelling/suggest/TestHighFrequencyDictionaryFactory.java index 356a945af49..001cf4fa2f4 100644 --- a/solr/core/src/test/org/apache/solr/spelling/suggest/TestHighFrequencyDictionaryFactory.java +++ b/solr/core/src/test/org/apache/solr/spelling/suggest/TestHighFrequencyDictionaryFactory.java @@ -36,8 +36,7 @@ public static void beforeClass() throws Exception { assertU(commit()); assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "", @@ -51,8 +50,7 @@ public void testDefault() { // tests to demonstrate default maxEdit parameter (value: 1), control for testWithMaxEdit2 assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "chagn", @@ -71,8 +69,7 @@ public void testDefault() { + "']/lst[@name='chagn']/arr[@name='suggestions']/lst[2]/str[@name='term'][.='change']"); assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "chacn", @@ -91,8 +88,7 @@ public void testDefault() { + "']/lst[@name='chacn']/arr[@name='suggestions']/lst[2]/str[@name='term'][.='change']"); assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "chagr", @@ -108,8 +104,7 @@ public void testDefault() { + "']/lst[@name='chagr']/arr[@name='suggestions']/lst[1]/str[@name='term'][.='charge']"); assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "chanr", @@ -122,8 +117,7 @@ public void testDefault() { + "']/lst[@name='chanr']/int[@name='numFound'][.='3']"); assertQ( - req( - "qt", + reqWithPath( REQUEST_URI, "q", "cyhnce", diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/TestPhraseSuggestions.java b/solr/core/src/test/org/apache/solr/spelling/suggest/TestPhraseSuggestions.java index f73f2f2407e..5aa3f9cf5e1 100644 --- a/solr/core/src/test/org/apache/solr/spelling/suggest/TestPhraseSuggestions.java +++ b/solr/core/src/test/org/apache/solr/spelling/suggest/TestPhraseSuggestions.java @@ -26,19 +26,19 @@ public class TestPhraseSuggestions extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-phrasesuggest.xml", "schema-phrasesuggest.xml"); - assertQ(req("qt", URI, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); + assertQ(reqWithPath(URI, "q", "", SpellingParams.SPELLCHECK_BUILD, "true")); } public void test() { assertQ( - req("qt", URI, "q", "the f", SpellingParams.SPELLCHECK_COUNT, "4"), + reqWithPath(URI, "q", "the f", SpellingParams.SPELLCHECK_COUNT, "4"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='the f']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='the f']/arr[@name='suggestion']/str[1][.='the final phrase']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='the f']/arr[@name='suggestion']/str[2][.='the fifth phrase']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='the f']/arr[@name='suggestion']/str[3][.='the first phrase']"); assertQ( - req("qt", URI, "q", "Testing +12", SpellingParams.SPELLCHECK_COUNT, "4"), + reqWithPath(URI, "q", "Testing +12", SpellingParams.SPELLCHECK_COUNT, "4"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='testing 12']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='testing 12']/arr[@name='suggestion']/str[1][.='testing 1234']"); } From c7073e8af0930a0db0268774dd81fa11408b6b54 Mon Sep 17 00:00:00 2001 From: Jason Gerlowski Date: Wed, 12 Aug 2026 21:49:28 -0400 Subject: [PATCH 5/6] Convert RTG/recovery/versions tests to reqWithPath Extends the reqWithPath conversion to the real-time-get, recovery, and versions test files, replacing req("qt", "/get", ...) with reqWithPath("/get", ...) so these tests no longer rely on the deprecated qt parameter to select the handler. --- .../solr/search/TestAddFieldRealTimeGet.java | 8 +- .../apache/solr/search/TestRealTimeGet.java | 93 +++++++++---------- .../org/apache/solr/search/TestRecovery.java | 69 +++++++------- .../org/apache/solr/search/TestReload.java | 6 +- .../solr/search/TestStressRecovery.java | 2 +- .../apache/solr/search/TestStressReorder.java | 2 +- .../solr/search/TestStressUserVersions.java | 2 +- .../solr/search/TestStressVersions.java | 2 +- .../org/apache/solr/update/UpdateLogTest.java | 4 +- 9 files changed, 91 insertions(+), 97 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/search/TestAddFieldRealTimeGet.java b/solr/core/src/test/org/apache/solr/search/TestAddFieldRealTimeGet.java index 91447cf037d..65555dc4560 100644 --- a/solr/core/src/test/org/apache/solr/search/TestAddFieldRealTimeGet.java +++ b/solr/core/src/test/org/apache/solr/search/TestAddFieldRealTimeGet.java @@ -73,10 +73,10 @@ public void test() throws Exception { assertU(adoc("id", "1", newFieldName, newFieldValue)); assertJQ(req("q", "id:1"), "/response/numFound==0"); assertJQ( - req("qt", "/get", "id", "1", "fl", "id," + newFieldName), + reqWithPath("/get", "id", "1", "fl", "id," + newFieldName), "=={'doc':{'id':'1'," + newFieldKeyValue + "}}"); assertJQ( - req("qt", "/get", "ids", "1", "fl", "id," + newFieldName), + reqWithPath("/get", "ids", "1", "fl", "id," + newFieldName), "=={'response':{'numFound':1,'start':0,'numFoundExact':true,'docs':[{'id':'1'," + newFieldKeyValue + "}]}}"); @@ -85,10 +85,10 @@ public void test() throws Exception { assertJQ(req("q", "id:1"), "/response/numFound==1"); assertJQ( - req("qt", "/get", "id", "1", "fl", "id," + newFieldName), + reqWithPath("/get", "id", "1", "fl", "id," + newFieldName), "=={'doc':{'id':'1'," + newFieldKeyValue + "}}"); assertJQ( - req("qt", "/get", "ids", "1", "fl", "id," + newFieldName), + reqWithPath("/get", "ids", "1", "fl", "id," + newFieldName), "=={'response':{'numFound':1,'start':0,'numFoundExact':true,'docs':[{'id':'1'," + newFieldKeyValue + "}]}}"); diff --git a/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java b/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java index 44749171af4..3ef6a1ab467 100644 --- a/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java +++ b/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java @@ -162,8 +162,7 @@ public void testGetRealtime() throws Exception { "false")); assertJQ(req("q", "id:1"), "/response/numFound==0"); assertJQ( - req( - "qt", + reqWithPath( "/get", "id", "1", @@ -181,7 +180,7 @@ public void testGetRealtime() throws Exception { + ", a_b:false, a_bd:true, a_bdS:false, a_bs:[true,false],a_bds:[true,false],a_bdsS:[true,false]" + " }}"); assertJQ( - req("qt", "/get", "ids", "1", "fl", "id"), + reqWithPath("/get", "ids", "1", "fl", "id"), "=={" + " 'response':{'numFound':1,'start':0,'numFoundExact':true,'docs':[" + " {" @@ -195,8 +194,7 @@ public void testGetRealtime() throws Exception { // a cut-n-paste of the first big query, but this time it will be retrieved from the index // rather than the transaction log assertJQ( - req( - "qt", + reqWithPath( "/get", "id", "1", @@ -209,9 +207,9 @@ public void testGetRealtime() throws Exception { + ", a_l:-9999999999, a_ld:-9999999999, a_ldS:-9999999999, a_ls:[1,9999999999],a_lds:[1,9999999999],a_ldsS:[1,9999999999]" + " }}"); - assertJQ(req("qt", "/get", "id", "1", "fl", "id"), "=={'doc':{'id':'1'}}"); + assertJQ(reqWithPath("/get", "id", "1", "fl", "id"), "=={'doc':{'id':'1'}}"); assertJQ( - req("qt", "/get", "ids", "1", "fl", "id"), + reqWithPath("/get", "ids", "1", "fl", "id"), "=={" + " 'response':{'numFound':1,'start':0,'numFoundExact':true,'docs':[" + " {" @@ -221,28 +219,30 @@ public void testGetRealtime() throws Exception { assertU(delI("1")); assertJQ(req("q", "id:1"), "/response/numFound==1"); - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':null}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':null}"); assertJQ( - req("qt", "/get", "ids", "1"), + reqWithPath("/get", "ids", "1"), "=={'response':{'numFound':0,'start':0,'numFoundExact':true,'docs':[]}}"); assertU(adoc("id", "10")); assertU(adoc("id", "11")); - assertJQ(req("qt", "/get", "id", "10", "fl", "id"), "=={'doc':{'id':'10'}}"); + assertJQ(reqWithPath("/get", "id", "10", "fl", "id"), "=={'doc':{'id':'10'}}"); assertU(delQ("id:10 foo_s:abcdef")); - assertJQ(req("qt", "/get", "id", "10"), "=={'doc':null}"); - assertJQ(req("qt", "/get", "id", "11", "fl", "id"), "=={'doc':{'id':'11'}}"); + assertJQ(reqWithPath("/get", "id", "10"), "=={'doc':null}"); + assertJQ(reqWithPath("/get", "id", "11", "fl", "id"), "=={'doc':{'id':'11'}}"); // multivalued field assertU(adoc("id", "12", "val_ls", "1", "val_ls", "2")); assertJQ(req("q", "id:12"), "/response/numFound==0"); assertJQ( - req("qt", "/get", "id", "12", "fl", "id,val_ls"), "=={'doc':{'id':'12', 'val_ls':[1,2]}}"); + reqWithPath("/get", "id", "12", "fl", "id,val_ls"), + "=={'doc':{'id':'12', 'val_ls':[1,2]}}"); assertU(commit()); assertJQ( - req("qt", "/get", "id", "12", "fl", "id,val_ls"), "=={'doc':{'id':'12', 'val_ls':[1,2]}}"); + reqWithPath("/get", "id", "12", "fl", "id,val_ls"), + "=={'doc':{'id':'12', 'val_ls':[1,2]}}"); assertJQ(req("q", "id:12"), "/response/numFound==1"); SolrQueryRequest req = req(); @@ -255,7 +255,7 @@ public void testGetRealtime() throws Exception { assertU(adoc("id", "13")); // this should not need to open another realtime searcher - assertJQ(req("qt", "/get", "id", "11", "fl", "id", "fq", "id:11"), "=={doc:{id:'11'}}"); + assertJQ(reqWithPath("/get", "id", "11", "fl", "id", "fq", "id:11"), "=={doc:{id:'11'}}"); // assert that the same realtime searcher is still in effect (i.e. that we didn't // open a new searcher when we didn't have to). @@ -266,29 +266,20 @@ public void testGetRealtime() throws Exception { realtimeHolder2.decref(); // filter most likely different segment - assertJQ(req("qt", "/get", "id", "12", "fl", "id", "fq", "id:11"), "=={doc:null}"); + assertJQ(reqWithPath("/get", "id", "12", "fl", "id", "fq", "id:11"), "=={doc:null}"); // filter most likely same different segment - assertJQ(req("qt", "/get", "id", "12", "fl", "id", "fq", "id:13"), "=={doc:null}"); + assertJQ(reqWithPath("/get", "id", "12", "fl", "id", "fq", "id:13"), "=={doc:null}"); - assertJQ(req("qt", "/get", "id", "12", "fl", "id", "fq", "id:12"), "=={doc:{id:'12'}}"); + assertJQ(reqWithPath("/get", "id", "12", "fl", "id", "fq", "id:12"), "=={doc:{id:'12'}}"); assertU(adoc("id", "14")); assertU(adoc("id", "15")); // id list, with some in index and some not, first id from index. Also test multiple fq params. assertJQ( - req( - "qt", - "/get", - "ids", - "12,14,13,15", - "fl", - "id", - "fq", - "id:[10 TO 14]", - "fq", - "id:[13 TO 19]"), + reqWithPath( + "/get", "ids", "12,14,13,15", "fl", "id", "fq", "id:[10 TO 14]", "fq", "id:[13 TO 19]"), "/response/docs==[{id:'14'},{id:'13'}]"); assertU(adoc("id", "16")); @@ -296,20 +287,20 @@ public void testGetRealtime() throws Exception { // id list, with some in index and some not, first id from tlog assertJQ( - req("qt", "/get", "ids", "17,16,15,14", "fl", "id", "fq", "id:[15 TO 16]"), + reqWithPath("/get", "ids", "17,16,15,14", "fl", "id", "fq", "id:[15 TO 16]"), "/response/docs==[{id:'16'},{id:'15'}]"); // more complex filter assertJQ( - req("qt", "/get", "ids", "17,16,15,14", "fl", "id", "fq", "{!frange l=15 u=16}id"), + reqWithPath("/get", "ids", "17,16,15,14", "fl", "id", "fq", "{!frange l=15 u=16}id"), "/response/docs==[{id:'16'},{id:'15'}]"); // test with negative filter assertJQ( - req("qt", "/get", "ids", "15,14", "fl", "id", "fq", "-id:15"), + reqWithPath("/get", "ids", "15,14", "fl", "id", "fq", "-id:15"), "/response/docs==[{id:'14'}]"); assertJQ( - req("qt", "/get", "ids", "17,16,15,14", "fl", "id", "fq", "-id:[15 TO 17]"), + reqWithPath("/get", "ids", "17,16,15,14", "fl", "id", "fq", "-id:[15 TO 17]"), "/response/docs==[{id:'14'}]"); realtimeHolder.decref(); @@ -326,11 +317,11 @@ public void testVersions() throws Exception { assertJQ(req("q", "id:1"), "/response/numFound==0"); // test version is there from rtg - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); // test version is there from the index assertU(commit()); - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); // simulate an update from the leader version += 10; @@ -339,7 +330,7 @@ public void testVersions() throws Exception { params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); // test version is there from rtg - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); // simulate reordering: test that a version less than that does not take effect updateJ( @@ -347,7 +338,7 @@ public void testVersions() throws Exception { params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); // test that version hasn't changed - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); // simulate reordering: test that a delete w/ version less than that does not take affect // TODO: also allow passing version on delete instead of on URL? @@ -356,7 +347,7 @@ public void testVersions() throws Exception { params(DISTRIB_UPDATE_PARAM, FROM_LEADER, "_version_", Long.toString(version - 1))); // test that version hasn't changed - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); // make sure reordering detection also works after a commit assertU(commit()); @@ -367,7 +358,7 @@ public void testVersions() throws Exception { params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); // test that version hasn't changed - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); // simulate reordering: test that a delete operation w/ version less than that does not take // effect @@ -376,7 +367,7 @@ public void testVersions() throws Exception { params(DISTRIB_UPDATE_PARAM, FROM_LEADER, "_version_", Long.toString(version - 1))); // test that version hasn't changed - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + version + "}}"); // now simulate a normal delete from the leader version += 5; @@ -390,7 +381,7 @@ public void testVersions() throws Exception { params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); // test that it's still deleted - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':null}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':null}"); // test that we can remember the version of a delete operation after a commit assertU(commit()); @@ -399,14 +390,14 @@ public void testVersions() throws Exception { long version2 = deleteByQueryAndGetVersion("id:2", null); // test that it's still deleted - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':null}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':null}"); version = addAndGetVersion(sdoc("id", "2"), null); version2 = deleteByQueryAndGetVersion("id:2", null); assertTrue(Math.abs(version2) > version); // test that it's deleted - assertJQ(req("qt", "/get", "id", "2"), "=={'doc':null}"); + assertJQ(reqWithPath("/get", "id", "2"), "=={'doc':null}"); version2 = Math.abs(version2) + 1000; updateJ( @@ -421,8 +412,8 @@ public void testVersions() throws Exception { "id:(3 4 5 6)", params(DISTRIB_UPDATE_PARAM, FROM_LEADER, "_version_", Long.toString(-(version2 + 150)))); - assertJQ(req("qt", "/get", "id", "3"), "=={'doc':null}"); - assertJQ(req("qt", "/get", "id", "4", "fl", "id"), "=={'doc':{'id':'4'}}"); + assertJQ(reqWithPath("/get", "id", "3"), "=={'doc':null}"); + assertJQ(reqWithPath("/get", "id", "4", "fl", "id"), "=={'doc':{'id':'4'}}"); updateJ( jsonAdd(sdoc("id", "5", "_version_", Long.toString(version2 + 201))), @@ -432,8 +423,8 @@ public void testVersions() throws Exception { params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); // the DBQ should also have caused id:6 to be removed - assertJQ(req("qt", "/get", "id", "5", "fl", "id"), "=={'doc':{'id':'5'}}"); - assertJQ(req("qt", "/get", "id", "6"), "=={'doc':null}"); + assertJQ(reqWithPath("/get", "id", "5", "fl", "id"), "=={'doc':{'id':'5'}}"); + assertJQ(reqWithPath("/get", "id", "6"), "=={'doc':null}"); assertU(commit()); } @@ -574,7 +565,8 @@ public void testOptimisticLocking() throws Exception { long lastVersion = version2; // sanity test that we see the right version via rtg - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + lastVersion + "}}"); + assertJQ( + reqWithPath("/get", "id", "1"), "=={'doc':{'id':'1','_version_':" + lastVersion + "}}"); } // @Test @@ -883,14 +875,13 @@ public void run() { boolean filteredOut = false; SolrQueryRequest sreq; if (realTime) { - ModifiableSolrParams p = - params("wt", "json", "qt", "/get", "ids", Integer.toString(id)); + ModifiableSolrParams p = params("wt", "json", "ids", Integer.toString(id)); if (rand.nextInt(100) < filteredGetPercent) { int idToFilter = rand.nextBoolean() ? id : rand.nextInt(ndocs); filteredOut = idToFilter != id; p.add("fq", "id:" + idToFilter); } - sreq = req(p); + sreq = reqWithPath("/get", p); } else { sreq = req("wt", "json", "q", "id:" + Integer.toString(id), "omitHeader", "true"); diff --git a/solr/core/src/test/org/apache/solr/search/TestRecovery.java b/solr/core/src/test/org/apache/solr/search/TestRecovery.java index e20a2d8cf27..2a40116c231 100644 --- a/solr/core/src/test/org/apache/solr/search/TestRecovery.java +++ b/solr/core/src/test/org/apache/solr/search/TestRecovery.java @@ -205,7 +205,7 @@ public void testLogReplay() throws Exception { addAndGetVersion(sdoc("id", "A12", "val_i_dvo", map("set", 2)), null)); // in-place update assertJQ(req("q", "*:*"), "/response/numFound==0"); - assertJQ(req("qt", "/get", "getVersions", "" + versions.size()), "/versions==" + versions); + assertJQ(reqWithPath("/get", "getVersions", "" + versions.size()), "/versions==" + versions); h.close(); createCore(); @@ -218,7 +218,7 @@ public void testLogReplay() throws Exception { assertJQ(req("q", "*:*"), "/response/numFound==0"); // make sure we can still access versions after a restart - assertJQ(req("qt", "/get", "getVersions", "" + versions.size()), "/versions==" + versions); + assertJQ(reqWithPath("/get", "getVersions", "" + versions.size()), "/versions==" + versions); assertEquals( UpdateLog.State.REPLAYING, h.getCore().getUpdateHandler().getUpdateLog().getState()); @@ -250,7 +250,7 @@ public void testLogReplay() throws Exception { logReplay.release(1000); // make sure we can still access versions during recovery - assertJQ(req("qt", "/get", "getVersions", "" + versions.size()), "/versions==" + versions); + assertJQ(reqWithPath("/get", "getVersions", "" + versions.size()), "/versions==" + versions); // wait until recovery has finished assertTrue(logReplayFinish.tryAcquire(timeout, TimeUnit.SECONDS)); @@ -274,7 +274,7 @@ public void testLogReplay() throws Exception { 0.0); // make sure we can still access versions after recovery - assertJQ(req("qt", "/get", "getVersions", "" + versions.size()), "/versions==" + versions); + assertJQ(reqWithPath("/get", "getVersions", "" + versions.size()), "/versions==" + versions); assertU(adoc("id", "A2")); assertU(adoc("id", "A3")); @@ -708,12 +708,14 @@ public void testBuffering() throws Exception { deleteAndGetVersion("B1", params(DISTRIB_UPDATE_PARAM, FROM_LEADER, "_version_", v2010_del)); assertJQ( - req("qt", "/get", "getVersions", "6"), "=={'versions':[" + versionListFirstCheck + "]}"); + reqWithPath("/get", "getVersions", "6"), + "=={'versions':[" + versionListFirstCheck + "]}"); assertU(commit()); assertJQ( - req("qt", "/get", "getVersions", "6"), "=={'versions':[" + versionListFirstCheck + "]}"); + reqWithPath("/get", "getVersions", "6"), + "=={'versions':[" + versionListFirstCheck + "]}"); // updates should be buffered, so we should not see any results yet. assertJQ(req("q", "*:*"), "/response/numFound==0"); @@ -721,7 +723,7 @@ public void testBuffering() throws Exception { // real-time get should also not show anything (this could change in the future), // but it's currently used for validating version numbers too, so it would // be bad for updates to be visible if we're just buffering. - assertJQ(req("qt", "/get", "id", "B3"), "=={'doc':null}"); + assertJQ(reqWithPath("/get", "id", "B3"), "=={'doc':null}"); var actualBufferedOpsValue = SolrMetricTestUtils.getGaugeDatapoint( @@ -746,7 +748,7 @@ public void testBuffering() throws Exception { assertEquals(6, actualAppliedBufferedOpsValue, 0.0); assertThatJQ( - req("qt", "/get", "getVersions", "6"), + reqWithPath("/get", "getVersions", "6"), "Incorrect ordering of versions during applyBufferedUpdates", versionsMatch( 6, @@ -771,7 +773,7 @@ public void testBuffering() throws Exception { ulog.bufferUpdates(); assertEquals(UpdateLog.State.BUFFERING, ulog.getState()); - Long ver = getVer(req("qt", "/get", "id", "B3")); + Long ver = getVer(reqWithPath("/get", "id", "B3")); assertEquals(Long.valueOf(v1030), ver); // add a reordered doc that shouldn't overwrite one in the index @@ -803,7 +805,7 @@ public void testBuffering() throws Exception { params(DISTRIB_UPDATE_PARAM, FROM_LEADER, "_version_", v3000_del)); assertThatJQ( - req("qt", "/get", "getVersions", "13"), + reqWithPath("/get", "getVersions", "13"), "Incorrect versions during buffering", versionsMatch( 13, @@ -963,7 +965,7 @@ public void testDropBuffered() throws Exception { assertEquals(2, rinfo.adds); assertThatJQ( - req("qt", "/get", "getVersions", "2"), + reqWithPath("/get", "getVersions", "2"), "Wrong updates after applyBufferedUpdates", versionsMatch( 2, @@ -1024,7 +1026,7 @@ public void testDropBuffered() throws Exception { // Note that the v101->v103 are dropped, therefore it does not present in RTG assertThatJQ( - req("qt", "/get", "getVersions", "6"), + reqWithPath("/get", "getVersions", "6"), "Incorrect versions after applyBufferedUpdates", versionsMatch( 6, @@ -1061,7 +1063,8 @@ public void testDropBuffered() throws Exception { assertU(commit()); - assertJQ(req("qt", "/get", "getVersions", "2"), "=={'versions':[" + v302 + "," + v301 + "]}"); + assertJQ( + reqWithPath("/get", "getVersions", "2"), "=={'versions':[" + v302 + "," + v301 + "]}"); assertJQ( req("q", "*:*", "sort", "_version_ desc", "fl", "id,_version_", "rows", "2"), @@ -1154,7 +1157,7 @@ public void testBufferedMultipleCalls() throws Exception { assertEquals(2, rinfo.adds); assertThatJQ( - req("qt", "/get", "getVersions", "2"), + reqWithPath("/get", "getVersions", "2"), "Wrong updates after applyBufferedUpdates", versionsMatch( 2, @@ -1214,7 +1217,7 @@ public void testBufferedMultipleCalls() throws Exception { + "]"); assertThatJQ( - req("qt", "/get", "getVersions", "6"), + reqWithPath("/get", "getVersions", "6"), "Incorrect versions after applyBufferedUpdates", versionsMatch( 6, @@ -1357,7 +1360,7 @@ public void testExistOldBufferLog() throws Exception { "Timeout waiting for finish replay updates", () -> h.getCore().getUpdateHandler().getUpdateLog().getState() == UpdateLog.State.ACTIVE); - assertJQ(req("qt", "/get", "id", "Q7"), "/doc/id==Q7"); + assertJQ(reqWithPath("/get", "id", "Q7"), "/doc/id==Q7"); } finally { UpdateLog.testing_logReplayHook = null; UpdateLog.testing_logReplayFinishHook = null; @@ -1391,7 +1394,7 @@ public void testVersionsOnRestart() throws Exception { assertTrue(D1Version2 > D1Version1); assertJQ( - req("qt", "/get", "getVersions", "2"), + reqWithPath("/get", "getVersions", "2"), "/versions==[" + D1Version2 + "," + D2Version1 + "]"); } @@ -1508,12 +1511,12 @@ public void testRemoveOldLogs() throws Exception { expectedToRetain + docsPerBatch); // not yet committed, so one more tlog could slip in assertJQ( - req("qt", "/get", "getVersions", "" + maxReq), + reqWithPath("/get", "getVersions", "" + maxReq), "/versions==" + versions.subList(0, Math.min(maxReq, versExpected))); assertU(commit()); versExpected = Math.min(numIndexed, expectedToRetain); assertJQ( - req("qt", "/get", "getVersions", "" + maxReq), + reqWithPath("/get", "getVersions", "" + maxReq), "/versions==" + versions.subList(0, Math.min(maxReq, versExpected))); assertEquals(Math.min(i, ulog.getMaxNumLogsToKeep()), ulog.getLogList(logDir).length); } @@ -1526,13 +1529,13 @@ public void testRemoveOldLogs() throws Exception { numIndexed += docsPerBatch; versExpected = Math.min(numIndexed, expectedToRetain); assertJQ( - req("qt", "/get", "getVersions", "" + maxReq), + reqWithPath("/get", "getVersions", "" + maxReq), "/versions==" + versions.subList(0, Math.min(maxReq, versExpected))); assertU(commit()); expectedToRetain = expectedToRetain - 1; // we lose a log entry due to the commit record versExpected = Math.min(numIndexed, expectedToRetain); assertJQ( - req("qt", "/get", "getVersions", "" + maxReq), + reqWithPath("/get", "getVersions", "" + maxReq), "/versions==" + versions.subList(0, Math.min(maxReq, versExpected))); // previous logs should be gone now @@ -1545,7 +1548,7 @@ public void testRemoveOldLogs() throws Exception { // test we can get versions while replay is happening assertJQ( - req("qt", "/get", "getVersions", "" + maxReq), + reqWithPath("/get", "getVersions", "" + maxReq), "/versions==" + versions.subList(0, Math.min(maxReq, expectedToRetain))); logReplay.release(1000); @@ -1554,7 +1557,7 @@ public void testRemoveOldLogs() throws Exception { expectedToRetain = expectedToRetain - 1; // we lose a log entry due to the commit record made by recovery assertJQ( - req("qt", "/get", "getVersions", "" + maxReq), + reqWithPath("/get", "getVersions", "" + maxReq), "/versions==" + versions.subList(0, Math.min(maxReq, expectedToRetain))); docsPerBatch = ulog.getNumRecordsToKeep() + 20; @@ -1564,12 +1567,12 @@ public void testRemoveOldLogs() throws Exception { addDocs(docsPerBatch, numIndexed, versions); numIndexed += docsPerBatch; assertJQ( - req("qt", "/get", "getVersions", "" + maxReq), + reqWithPath("/get", "getVersions", "" + maxReq), "/versions==" + versions.subList(0, Math.min(maxReq, expectedToRetain))); assertU(commit()); expectedToRetain = expectedToRetain - 1; // we lose a log entry due to the commit record assertJQ( - req("qt", "/get", "getVersions", "" + maxReq), + reqWithPath("/get", "getVersions", "" + maxReq), "/versions==" + versions.subList(0, Math.min(maxReq, expectedToRetain))); // previous logs should be gone now @@ -1597,7 +1600,7 @@ public void testRemoveOldLogs() throws Exception { createCore(); // we should still be able to get the list of versions (not including the trashed log file) assertJQ( - req("qt", "/get", "getVersions", "" + maxReq), + reqWithPath("/get", "getVersions", "" + maxReq), "/versions==" + versions.subList(0, Math.min(maxReq, expectedToRetain))); resetExceptionIgnores(); @@ -1677,9 +1680,9 @@ public void testTruncatedLog() throws Exception { // This currently skips the bad log file and also returns the version of the clearIndex (del // *:*) - // assertJQ(req("qt","/get", "getVersions","6"), "/versions==[106,105,104]"); + // assertJQ(reqWithPath("/get", "getVersions", "6"), "/versions==[106,105,104]"); assertJQ( - req("qt", "/get", "getVersions", "3"), + reqWithPath("/get", "getVersions", "3"), "/versions==[" + v106 + "," + v105 + "," + v104 + "]"); } finally { @@ -1742,7 +1745,7 @@ public void testCorruptLog() throws Exception { // This currently skips the bad log file and also returns the version of the clearIndex (del // *:*) assertJQ( - req("qt", "/get", "getVersions", "3"), + reqWithPath("/get", "getVersions", "3"), "/versions==[" + v106 + "," + v105 + "," + v104 + "]"); assertU(commit()); @@ -1906,7 +1909,7 @@ public void testLogReplayWithInPlaceUpdatesAndDeletes() throws Exception { assertJQ(req("q", "*:*"), "/response/numFound==0"); - assertJQ(req("qt", "/get", "getVersions", "" + versions.size()), "/versions==" + versions); + assertJQ(reqWithPath("/get", "getVersions", "" + versions.size()), "/versions==" + versions); h.close(); createCore(); @@ -1919,13 +1922,13 @@ public void testLogReplayWithInPlaceUpdatesAndDeletes() throws Exception { assertJQ(req("q", "*:*"), "/response/numFound==0"); // make sure we can still access versions after a restart - assertJQ(req("qt", "/get", "getVersions", "" + versions.size()), "/versions==" + versions); + assertJQ(reqWithPath("/get", "getVersions", "" + versions.size()), "/versions==" + versions); // unblock recovery logReplay.release(1000); // make sure we can still access versions during recovery - assertJQ(req("qt", "/get", "getVersions", "" + versions.size()), "/versions==" + versions); + assertJQ(reqWithPath("/get", "getVersions", "" + versions.size()), "/versions==" + versions); // wait until recovery has finished assertTrue(logReplayFinish.tryAcquire(timeout, TimeUnit.SECONDS)); @@ -1940,7 +1943,7 @@ public void testLogReplayWithInPlaceUpdatesAndDeletes() throws Exception { assertJQ(req("q", "id:A5"), "/response/numFound==0"); // make sure we can still access versions after recovery - assertJQ(req("qt", "/get", "getVersions", "" + versions.size()), "/versions==" + versions); + assertJQ(reqWithPath("/get", "getVersions", "" + versions.size()), "/versions==" + versions); assertU(adoc("id", "A10")); diff --git a/solr/core/src/test/org/apache/solr/search/TestReload.java b/solr/core/src/test/org/apache/solr/search/TestReload.java index ecf88cfaeda..f9f04676378 100644 --- a/solr/core/src/test/org/apache/solr/search/TestReload.java +++ b/solr/core/src/test/org/apache/solr/search/TestReload.java @@ -37,13 +37,13 @@ public void testGetRealtimeReload() throws Exception { assertU(commit("softCommit", "true")); // should cause a RTG searcher to be opened assertJQ( - req("qt", "/get", "id", "1", "fl", "id,_version_"), + reqWithPath("/get", "id", "1", "fl", "id,_version_"), "=={'doc':{'id':'1','_version_':" + version + "}}"); h.reload(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,_version_"), + reqWithPath("/get", "id", "1", "fl", "id,_version_"), "=={'doc':{'id':'1','_version_':" + version + "}}"); assertU(commit("softCommit", "true")); // open a normal (caching) NRT searcher @@ -75,7 +75,7 @@ public void testGetRealtimeReload() throws Exception { // RTG should always be able to see the last version // System.out.println("!!! rtg"); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,_version_"), + reqWithPath("/get", "id", "1", "fl", "id,_version_"), "=={'doc':{'id':'1','_version_':" + version + "}}"); } diff --git a/solr/core/src/test/org/apache/solr/search/TestStressRecovery.java b/solr/core/src/test/org/apache/solr/search/TestStressRecovery.java index 299a8b82cf0..e1148b2ec12 100644 --- a/solr/core/src/test/org/apache/solr/search/TestStressRecovery.java +++ b/solr/core/src/test/org/apache/solr/search/TestStressRecovery.java @@ -323,7 +323,7 @@ public void run() { } SolrQueryRequest sreq; if (realTime) { - sreq = req("wt", "json", "qt", "/get", "ids", Integer.toString(id)); + sreq = reqWithPath("/get", "wt", "json", "ids", Integer.toString(id)); } else { sreq = req("wt", "json", "q", "id:" + Integer.toString(id), "omitHeader", "true"); diff --git a/solr/core/src/test/org/apache/solr/search/TestStressReorder.java b/solr/core/src/test/org/apache/solr/search/TestStressReorder.java index 54917fa7399..16fedf9cac3 100644 --- a/solr/core/src/test/org/apache/solr/search/TestStressReorder.java +++ b/solr/core/src/test/org/apache/solr/search/TestStressReorder.java @@ -324,7 +324,7 @@ public void run() { } SolrQueryRequest sreq; if (realTime) { - sreq = req("wt", "json", "qt", "/get", "ids", Integer.toString(id)); + sreq = reqWithPath("/get", "wt", "json", "ids", Integer.toString(id)); } else { sreq = req("wt", "json", "q", "id:" + Integer.toString(id), "omitHeader", "true"); diff --git a/solr/core/src/test/org/apache/solr/search/TestStressUserVersions.java b/solr/core/src/test/org/apache/solr/search/TestStressUserVersions.java index 3314b913f6d..35ce1aabd3d 100644 --- a/solr/core/src/test/org/apache/solr/search/TestStressUserVersions.java +++ b/solr/core/src/test/org/apache/solr/search/TestStressUserVersions.java @@ -288,7 +288,7 @@ public void run() { } SolrQueryRequest sreq; if (realTime) { - sreq = req("wt", "json", "qt", "/get", "ids", Integer.toString(id)); + sreq = reqWithPath("/get", "wt", "json", "ids", Integer.toString(id)); } else { sreq = req("wt", "json", "q", "id:" + Integer.toString(id), "omitHeader", "true"); diff --git a/solr/core/src/test/org/apache/solr/search/TestStressVersions.java b/solr/core/src/test/org/apache/solr/search/TestStressVersions.java index 03adc37a47a..72c99bf3ba8 100644 --- a/solr/core/src/test/org/apache/solr/search/TestStressVersions.java +++ b/solr/core/src/test/org/apache/solr/search/TestStressVersions.java @@ -231,7 +231,7 @@ public void run() { } SolrQueryRequest sreq; if (realTime) { - sreq = req("wt", "json", "qt", "/get", "ids", Integer.toString(id)); + sreq = reqWithPath("/get", "wt", "json", "ids", Integer.toString(id)); } else { sreq = req("wt", "json", "q", "id:" + Integer.toString(id), "omitHeader", "true"); diff --git a/solr/core/src/test/org/apache/solr/update/UpdateLogTest.java b/solr/core/src/test/org/apache/solr/update/UpdateLogTest.java index c951ad9141c..d98ce25efa1 100644 --- a/solr/core/src/test/org/apache/solr/update/UpdateLogTest.java +++ b/solr/core/src/test/org/apache/solr/update/UpdateLogTest.java @@ -200,7 +200,7 @@ public void testApplyPartialUpdatesWithDelete() throws Exception { // sanity check that the update log has one document, and RTG returns the document assertEquals(1, ulog.map.size()); assertJQ( - req("qt", "/get", "id", "1"), + reqWithPath("/get", "id", "1"), "=={'doc':{ 'id':'1', 'val1_i_dvo':3, '_version_':102, 'title_s':'title1', " // fields with default values + "'inplace_updatable_int_with_default':666, 'inplace_updatable_float_with_default':42.0}}"); @@ -215,7 +215,7 @@ public void testApplyPartialUpdatesWithDelete() throws Exception { assertTrue(String.valueOf(ulog.prevMap), ulog.prevMap == null || ulog.prevMap.size() == 0); assertTrue(String.valueOf(ulog.prevMap2), ulog.prevMap2 == null || ulog.prevMap2.size() == 0); // verify that the document is deleted, by doing an RTG call - assertJQ(req("qt", "/get", "id", "1"), "=={'doc':null}"); + assertJQ(reqWithPath("/get", "id", "1"), "=={'doc':null}"); } else { // dbi List entry = ((List) ulog.lookup(DOC_1_INDEXED_ID)); assertEquals( From c16e85eff696042f89b516f64ae332c4e4859c9c Mon Sep 17 00:00:00 2001 From: Jason Gerlowski Date: Wed, 12 Aug 2026 22:16:22 -0400 Subject: [PATCH 6/6] Convert update-processor, schema, and misc handler tests to reqWithPath Continues the reqWithPath conversion into the update-processor tests (AtomicUpdatesTest, NestedAtomicUpdateTest, TestDocBasedVersionConstraints, TestInPlaceUpdatesStandalone, TestUpdate), the /get-based schema tests (BooleanFieldTest, TestPointFields, TestPseudoReturnFields), and a mix of other req()+assertQ call sites (AlternateDirectoryTest, RequestHandlersTest, SegmentsInfoRequestHandlerTest, LukeRequestHandlerTest, MinimalSchemaTest, DisMaxRequestHandlerTest, PhrasesIdentificationComponentTest, ResponseLogComponentTest) that relied on the deprecated qt parameter to select a handler. --- .../apache/solr/DisMaxRequestHandlerTest.java | 37 ++++------ .../org/apache/solr/MinimalSchemaTest.java | 18 ++--- .../solr/core/AlternateDirectoryTest.java | 2 +- .../apache/solr/core/RequestHandlersTest.java | 4 +- .../handler/admin/LukeRequestHandlerTest.java | 32 ++++----- .../admin/SegmentsInfoRequestHandlerTest.java | 13 ++-- .../PhrasesIdentificationComponentTest.java | 8 +-- .../component/ResponseLogComponentTest.java | 15 ++-- .../apache/solr/schema/BooleanFieldTest.java | 2 +- .../apache/solr/schema/TestPointFields.java | 8 +-- .../solr/search/TestPseudoReturnFields.java | 51 +++++++------ .../update/TestInPlaceUpdatesStandalone.java | 8 +-- .../org/apache/solr/update/TestUpdate.java | 22 +++--- .../update/processor/AtomicUpdatesTest.java | 18 ++--- .../processor/NestedAtomicUpdateTest.java | 42 +++++------ .../TestDocBasedVersionConstraints.java | 72 ++++++++++--------- 16 files changed, 167 insertions(+), 185 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/DisMaxRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/DisMaxRequestHandlerTest.java index e82df1e4bfb..059921fa406 100644 --- a/solr/core/src/test/org/apache/solr/DisMaxRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/DisMaxRequestHandlerTest.java @@ -127,7 +127,7 @@ public void doTestSomeStuff(final String qt) { assertQ( "multi qf", - req("q", "cool", "qt", qt, "qf", "subject", "qf", "features_t"), + reqWithPath(qt, "q", "cool", "qf", "subject", "qf", "features_t"), "//*[@numFound='3']"); assertQ( @@ -137,7 +137,7 @@ public void doTestSomeStuff(final String qt) { assertQ( "boost query", - req("q", "cool stuff", "qt", qt, "bq", "subject:hell^400"), + reqWithPath(qt, "q", "cool stuff", "bq", "subject:hell^400"), "//*[@numFound='3']", "//result/doc[1]/str[@name='id'][.='666']", "//result/doc[2]/str[@name='id'][.='42']", @@ -145,11 +145,10 @@ public void doTestSomeStuff(final String qt) { assertQ( "multi boost query", - req( + reqWithPath( + qt, "q", "cool stuff", - "qt", - qt, "bq", "subject:hell^400", "bq", @@ -172,29 +171,19 @@ public void doTestSomeStuff(final String qt) { assertQ( "relying on ALTQ from config", - req( - "qt", qt, - "fq", "id:666", - "facet", "false"), + reqWithPath(qt, "fq", "id:666", "facet", "false"), "//*[@numFound='1']"); assertQ( "explicit ALTQ", - req( - "qt", qt, - "q.alt", "id:9999", - "fq", "id:666", - "facet", "false"), + reqWithPath(qt, "q.alt", "id:9999", "fq", "id:666", "facet", "false"), "//*[@numFound='0']"); assertQ( - "no query slop == no match", req("qt", qt, "q", "\"cool chick\""), "//*[@numFound='0']"); + "no query slop == no match", reqWithPath(qt, "q", "\"cool chick\""), "//*[@numFound='0']"); assertQ( "query slop == match", - req( - "qt", qt, - "qs", "2", - "q", "\"cool chick\""), + reqWithPath(qt, "qs", "2", "q", "\"cool chick\""), "//*[@numFound='1']"); } @@ -228,11 +217,10 @@ public void testExtraBlankBQ() throws Exception { Pattern p_bool = Pattern.compile("\\(subject:hell\\s*subject:cool\\)"); String resp = h.query( - req( + reqWithPath( + "/dismax", "q", "cool stuff", - "qt", - "/dismax", "bq", "subject:hell OR subject:cool", CommonParams.DEBUG_QUERY, @@ -242,11 +230,10 @@ public void testExtraBlankBQ() throws Exception { resp = h.query( - req( + reqWithPath( + "/dismax", "q", "cool stuff", - "qt", - "/dismax", "bq", "subject:hell OR subject:cool", "bq", diff --git a/solr/core/src/test/org/apache/solr/MinimalSchemaTest.java b/solr/core/src/test/org/apache/solr/MinimalSchemaTest.java index 2241f4d58b7..837aa2e4cca 100644 --- a/solr/core/src/test/org/apache/solr/MinimalSchemaTest.java +++ b/solr/core/src/test/org/apache/solr/MinimalSchemaTest.java @@ -71,13 +71,12 @@ public void testSimpleQueries() { @Test public void testLuke() { - assertQ("basic luke request failed", req("qt", "/admin/luke"), "//int[@name='numDocs'][.='2']"); + assertQ( + "basic luke request failed", reqWithPath("/admin/luke"), "//int[@name='numDocs'][.='2']"); assertQ( "luke show schema failed", - req( - "qt", "/admin/luke", - "show", "schema"), + reqWithPath("/admin/luke", "show", "schema"), "//int[@name='numDocs'][.='2']", "//null[@name='uniqueKeyField']"); } @@ -111,11 +110,12 @@ public void testAllConfiguredHandlers() { assertQ( "failure w/handler: '" + handler + "'", - req( - "qt", handler, - // this should be fairly innocuous for any type of query - "q", "foo:bar", - "omitHeader", "false"), + reqWithPath( + handler, // this should be fairly innocuous for any type of query + "q", + "foo:bar", + "omitHeader", + "false"), "//lst[@name='responseHeader']"); } catch (Exception e) { throw new RuntimeException("exception w/handler: '" + handler + "'", e); diff --git a/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java b/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java index 53603a1f931..efd1ebc0320 100644 --- a/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java +++ b/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java @@ -33,7 +33,7 @@ public static void beforeClass() throws Exception { } public void testAltDirectoryUsed() { - assertQ(req("q", "*:*", "qt", "/select")); + assertQ(reqWithPath("/select", "q", "*:*")); assertTrue(TestFSDirectoryFactory.openCalled); assertTrue(TestIndexReaderFactory.newReaderCalled); } diff --git a/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java b/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java index c332f264486..5962b3b7ac9 100644 --- a/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java +++ b/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java @@ -88,12 +88,12 @@ public void testLazyLoading() { // But it should behave just like the 'defaults' request handler above assertQ( "lazy handler returns fewer matches", - req("q", "id:[42 TO 47]", "qt", "/lazy"), + reqWithPath("/lazy", "q", "id:[42 TO 47]"), "*[count(//doc)=4]"); assertQ( "lazy handler includes highlighting", - req("q", "name:Zapp OR title:General", "qt", "/lazy"), + reqWithPath("/lazy", "q", "name:Zapp OR title:General"), "//lst[@name='highlighting']"); } diff --git a/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java index 5fa90f325a8..1d4b56fe2bc 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java @@ -112,13 +112,13 @@ private void assertHistoBucket(int slot, int in) { public void testLuke() { // test that Luke can handle all the field types - assertQ(req("qt", "/admin/luke", "id", "SOLR1000")); + assertQ(reqWithPath("/admin/luke", "id", "SOLR1000")); final int numFlags = EnumSet.allOf(FieldFlag.class).size(); assertQ( "Not all flags (" + numFlags + ") mentioned in info->key", - req("qt", "/admin/luke"), + reqWithPath("/admin/luke"), numFlags + "=count(//lst[@name='info']/lst[@name='key']/str)"); // code should be the same for all fields, but just in case do several @@ -129,7 +129,7 @@ public void testLuke() { final String xp = getFieldXPathPrefix(f); assertQ( "Not as many schema flags as expected (" + numFlags + ") for " + f, - req("qt", "/admin/luke", "fl", f), + reqWithPath("/admin/luke", "fl", f), numFlags + "=string-length(" + xp + "[@name='schema'])"); } @@ -140,13 +140,13 @@ public void testLuke() { final String xp = getFieldXPathPrefix(f); assertQ( "Not as many index flags as expected (" + numFlags + ") for " + f, - req("qt", "/admin/luke", "fl", f), + reqWithPath("/admin/luke", "fl", f), numFlags + "=string-length(" + xp + "[@name='index'])"); final String hxp = getFieldXPathHistogram(f); assertQ( "Historgram field should be present for field " + f, - req("qt", "/admin/luke", "fl", f), + reqWithPath("/admin/luke", "fl", f), hxp + "[@name='histogram']"); } } @@ -169,7 +169,7 @@ private static String dynfield(String field) { @Test public void testFlParam() { - SolrQueryRequest req = req("qt", "/admin/luke", "fl", "solr_t solr_s", "show", "all"); + SolrQueryRequest req = reqWithPath("/admin/luke", "fl", "solr_t solr_s", "show", "all"); try { // First, determine that the two fields ARE there String response = h.query(req); @@ -186,7 +186,7 @@ public void testFlParam() { TestHarness.validateXPath(response, getFieldXPathPrefix(f) + "[@name='index']")); } // Insure * works - req = req("qt", "/admin/luke", "fl", "*"); + req = reqWithPath("/admin/luke", "fl", "*"); response = h.query(req); for (String f : Arrays.asList("solr_t", "solr_s", "solr_ti", "solr_td", "solr_dt", "solr_b")) { @@ -202,25 +202,25 @@ public void testNumTerms() { final String f = "name"; for (String n : new String[] {"2", "3", "100", "99999"}) { assertQ( - req("qt", "/admin/luke", "fl", f, "numTerms", n), + reqWithPath("/admin/luke", "fl", f, "numTerms", n), field(f) + "lst[@name='topTerms']/int[@name='Apache']", field(f) + "lst[@name='topTerms']/int[@name='Solr']", "count(" + field(f) + "lst[@name='topTerms']/int)=2"); } assertQ( - req("qt", "/admin/luke", "fl", f, "numTerms", "1"), + reqWithPath("/admin/luke", "fl", f, "numTerms", "1"), // no guarantee which one we find "count(" + field(f) + "lst[@name='topTerms']/int)=1"); assertQ( - req("qt", "/admin/luke", "fl", f, "numTerms", "0"), + reqWithPath("/admin/luke", "fl", f, "numTerms", "0"), "count(" + field(f) + "lst[@name='topTerms']/int)=0"); // field with no terms shouldn't error for (String n : new String[] {"0", "1", "2", "100", "99999"}) { assertQ( - req("qt", "/admin/luke", "fl", "bogus_s", "numTerms", n), + reqWithPath("/admin/luke", "fl", "bogus_s", "numTerms", n), "count(" + field(f) + "lst[@name='topTerms']/int)=0"); } } @@ -234,7 +234,7 @@ public void testNullFactories() throws Exception { try { assertQ( - req("qt", "/admin/luke", "show", "schema"), + reqWithPath("/admin/luke", "show", "schema"), "//lst[@name='custom_tc_string']/lst[@name='indexAnalyzer']", "//lst[@name='custom_tc_string']/lst[@name='queryAnalyzer']", "0=count(//lst[@name='custom_tc_string']/lst[@name='indexAnalyzer']/lst[@name='filters'])", @@ -249,7 +249,7 @@ public void testNullFactories() throws Exception { } public void testCopyFieldLists() throws Exception { - SolrQueryRequest req = req("qt", "/admin/luke", "show", "schema"); + SolrQueryRequest req = reqWithPath("/admin/luke", "show", "schema"); String xml = h.query(req); String r = @@ -284,7 +284,7 @@ public void testCatchAllCopyField() throws Exception { " is missing from the schema", foundCatchAllCopyField); - SolrQueryRequest req = req("qt", "/admin/luke", "show", "schema", "indent", "on"); + SolrQueryRequest req = reqWithPath("/admin/luke", "show", "schema", "indent", "on"); String xml = h.query(req); String result = TestHarness.validateXPath( @@ -323,7 +323,7 @@ public void testIndexFlagsWithDeletedDocs() throws Exception { assertQ( "index flags should be present for solr_s despite deletion in segment", - req("qt", "/admin/luke", "fl", "solr_s"), + reqWithPath("/admin/luke", "fl", "solr_s"), getFieldXPathPrefix("solr_s") + "[@name='index']"); // Now test the inverse: delete the edges and keep the middle. The first term @@ -342,7 +342,7 @@ public void testIndexFlagsWithDeletedDocs() throws Exception { assertQ( "index flags should be present for solr_s when edges are deleted", - req("qt", "/admin/luke", "fl", "solr_s"), + reqWithPath("/admin/luke", "fl", "solr_s"), getFieldXPathPrefix("solr_s") + "[@name='index']"); } finally { deleteCore(); diff --git a/solr/core/src/test/org/apache/solr/handler/admin/SegmentsInfoRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/SegmentsInfoRequestHandlerTest.java index 260953b7bc9..0098bb94e65 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/SegmentsInfoRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/SegmentsInfoRequestHandlerTest.java @@ -97,7 +97,7 @@ public static void afterClass() throws Exception { public void testSegmentInfos() { assertQ( "Unexpected number of segments returned", - req("qt", "/admin/segments"), + reqWithPath("/admin/segments"), NUM_SEGMENTS + "=count(//lst[@name='segments']/lst)"); } @@ -105,7 +105,7 @@ public void testSegmentInfos() { public void testSegmentInfosVersion() { assertQ( "Unexpected number of segments returned", - req("qt", "/admin/segments"), + reqWithPath("/admin/segments"), NUM_SEGMENTS + "=count(//lst[@name='segments']/lst/str[@name='version'][.='" + Version.LATEST @@ -129,14 +129,15 @@ public void testSegmentNames() throws IOException { return null; }); - assertQ("Unexpected segment names returned", req("qt", "/admin/segments"), segmentNamePatterns); + assertQ( + "Unexpected segment names returned", reqWithPath("/admin/segments"), segmentNamePatterns); } @Test public void testSegmentInfosData() { assertQ( "Unexpected document counts in result", - req("qt", "/admin/segments"), + reqWithPath("/admin/segments"), // #Document (DOC_COUNT * 2) + "=sum(//lst[@name='segments']/lst/int[@name='size'])", // #Deletes @@ -147,7 +148,7 @@ public void testSegmentInfosData() { public void testCoreInfo() { assertQ( "Missing core info", - req("qt", "/admin/segments", "coreInfo", "true"), + reqWithPath("/admin/segments", "coreInfo", "true"), "boolean(//lst[@name='info']/lst[@name='core'])"); } @@ -193,7 +194,7 @@ public void testFieldInfo() throws Exception { }); assertQ( "Unexpected field infos returned", - req("qt", "/admin/segments", "fieldInfo", "true"), + reqWithPath("/admin/segments", "fieldInfo", "true"), segmentNamePatterns); } } diff --git a/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java index 6943af05e1c..262034f5dd2 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java @@ -651,9 +651,7 @@ public void testExpectedUserErrors() { assertQEx( "no query param should error", "requires a query string", - req( - "qt", "/phrases", - "phrases.fields", "multigrams_title"), + reqWithPath("/phrases", "phrases.fields", "multigrams_title"), ErrorCode.BAD_REQUEST); } @@ -696,7 +694,7 @@ public void testSimplePhraseRequest() { for (String p : Arrays.asList("q", "phrases.q")) { // basic request... assertQ( - req("qt", HANDLER, p, input), // expect no search results... + reqWithPath(HANDLER, p, input), // expect no search results... "count(//result)=0", // just phrase info... "//lst[@name='phrases']/str[@name='input'][.='" + input + "']", "//lst[@name='phrases']/str[@name='summary'][.='" + expected + "']", @@ -712,7 +710,7 @@ public void testSimplePhraseRequest() { // empty input, empty phrases (and no error)... assertQ( - req("qt", HANDLER, p, ""), // expect no search results... + reqWithPath(HANDLER, p, ""), // expect no search results... "count(//result)=0", // just empty phrase info for our empty input... "//lst[@name='phrases']/str[@name='input'][.='']", "//lst[@name='phrases']/str[@name='summary'][.='']", diff --git a/solr/core/src/test/org/apache/solr/handler/component/ResponseLogComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/ResponseLogComponentTest.java index 569bed2b463..59911357db5 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/ResponseLogComponentTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/ResponseLogComponentTest.java @@ -40,11 +40,10 @@ public void testToLogIds() throws Exception { try { String handler = "/withlog"; req = - req( + reqWithPath( + "/withlog", "indent", "true", - "qt", - "/withlog", "q", "aa", "rows", @@ -69,11 +68,10 @@ public void testToLogScores() throws Exception { try { String handler = "/withlog"; req = - req( + reqWithPath( + "/withlog", "indent", "true", - "qt", - "/withlog", "q", "aa", "rows", @@ -98,11 +96,10 @@ public void testDisabling() throws Exception { try { String handler = "/withlog"; req = - req( + reqWithPath( + "/withlog", "indent", "true", - "qt", - "/withlog", "q", "aa", "rows", diff --git a/solr/core/src/test/org/apache/solr/schema/BooleanFieldTest.java b/solr/core/src/test/org/apache/solr/schema/BooleanFieldTest.java index a2cbb5759bc..584fc3bc6f8 100644 --- a/solr/core/src/test/org/apache/solr/schema/BooleanFieldTest.java +++ b/solr/core/src/test/org/apache/solr/schema/BooleanFieldTest.java @@ -116,7 +116,7 @@ public void testBoolField() { // do atomic update assertU(adoc(sdoc("id", "7", "bindsto", Map.of("set", "1")))); assertQ( - req("qt", "/get", "id", "7"), + reqWithPath("/get", "id", "7"), "count(//doc)=1", "//doc/str[@name='id'][.='7']", "//doc/bool[@name='bindsto'][.='true']"); diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java index 4c7010bb0c1..9c7cc156c99 100644 --- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java +++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java @@ -3433,7 +3433,7 @@ private void doTestPointFieldReturn(String field, String type, String[] values) if (Boolean.getBoolean("solr.index.updatelog.enabled")) { for (int i = 0; i < values.length; i++) { assertQ( - req("qt", "/get", "id", String.valueOf(i)), + reqWithPath("/get", "id", String.valueOf(i)), "//doc/" + type + "[@name='" + field + "'][.='" + values[i] + "']"); } } @@ -3458,7 +3458,7 @@ private void doTestPointFieldReturn(String field, String type, String[] values) if (Boolean.getBoolean("solr.index.updatelog.enabled")) { for (int i = 0; i < values.length; i++) { assertQ( - req("qt", "/get", "id", String.valueOf(i)), + reqWithPath("/get", "id", String.valueOf(i)), "//doc/" + type + "[@name='" + field + "'][.='" + values[i] + "']"); } } @@ -4080,7 +4080,7 @@ private void doTestPointFieldMultiValuedReturn(String fieldName, String type, St if (Boolean.getBoolean("solr.index.updatelog.enabled")) { for (int i = 0; i < 10; i++) { assertQ( - req("qt", "/get", "id", String.valueOf(i)), + reqWithPath("/get", "id", String.valueOf(i)), "//doc/arr[@name='" + fieldName + "']/" + type + "[.='" + numbers[i] + "']", "//doc/arr[@name='" + fieldName + "']/" + type + "[.='" + numbers[i + 10] + "']", "count(//doc/arr[@name='" + fieldName + "']/" + type + ")=2"); @@ -4091,7 +4091,7 @@ private void doTestPointFieldMultiValuedReturn(String fieldName, String type, St if (Boolean.getBoolean("solr.index.updatelog.enabled")) { for (int i = 0; i < 10; i++) { assertQ( - req("qt", "/get", "id", String.valueOf(i)), + reqWithPath("/get", "id", String.valueOf(i)), "//doc/arr[@name='" + fieldName + "']/" + type + "[.='" + numbers[i] + "']", "//doc/arr[@name='" + fieldName + "']/" + type + "[.='" + numbers[i + 10] + "']", "count(//doc/arr[@name='" + fieldName + "']/" + type + ")=2"); diff --git a/solr/core/src/test/org/apache/solr/search/TestPseudoReturnFields.java b/solr/core/src/test/org/apache/solr/search/TestPseudoReturnFields.java index 1d3d3ca45bd..2fee5d8f858 100644 --- a/solr/core/src/test/org/apache/solr/search/TestPseudoReturnFields.java +++ b/solr/core/src/test/org/apache/solr/search/TestPseudoReturnFields.java @@ -93,7 +93,7 @@ public void testMultiValued() throws Exception { "/response/docs==[{'val2_ss':10,'val_ss':1}]"); assertJQ( - req("qt", "/get", "id", "42", "fl", "val_ss:val_i, val2_ss:10"), + reqWithPath("/get", "id", "42", "fl", "val_ss:val_i, val2_ss:10"), "/doc=={'val2_ss':10,'val_ss':1}"); } @@ -101,12 +101,12 @@ public void testMultiValuedRTG() throws Exception { // single value int using alias that matches multivalued dynamic field - via RTG assertJQ( - req("qt", "/get", "id", "42", "fl", "val_ss:val_i, val2_ss:10, subject"), + reqWithPath("/get", "id", "42", "fl", "val_ss:val_i, val2_ss:10, subject"), "/doc=={'val2_ss':10,'val_ss':1, 'subject':'aaa'}"); // also check real-time-get from transaction log assertJQ( - req("qt", "/get", "id", "99", "fl", "val_ss:val_i, val2_ss:10, subject"), + reqWithPath("/get", "id", "99", "fl", "val_ss:val_i, val2_ss:10, subject"), "/doc=={'val2_ss':10,'val_ss':1,'subject':'uncommitted'}"); } @@ -145,7 +145,7 @@ public void testAllRealFieldsRTG() { for (String id : Arrays.asList("42", "99")) { assertQ( "id=" + id + ", fl=" + fl + " ... all real fields", - req("qt", "/get", "id", id, "wt", "xml", "fl", fl), + reqWithPath("/get", "id", id, "wt", "xml", "fl", fl), "count(//doc)=1", "//doc/str[@name='id']", "//doc/int[@name='val_i']", @@ -161,8 +161,7 @@ public void testFilterAndOneRealFieldRTG() { // only one of these docs should match... assertQ( "RTG w/ 2 ids & fq that only matches 1 uncommitted doc", - req( - "qt", + reqWithPath( "/get", "ids", "42,99", @@ -203,7 +202,7 @@ public void testScoreAndAllRealFieldsRTG() { for (String id : Arrays.asList("42", "99")) { assertQ( "id=" + id + ", fl=" + fl + " ... score real fields", - req("qt", "/get", "id", id, "wt", "xml", "fl", fl), + reqWithPath("/get", "id", id, "wt", "xml", "fl", fl), "count(//doc)=1", "//doc/str[@name='id']", "//doc/int[@name='val_i']", @@ -244,7 +243,7 @@ public void testScoreAndExplicitRealFieldsRTG() { for (String id : Arrays.asList("42", "99")) { assertQ( "id=" + id + ", fl=score,val_i", - req("qt", "/get", "id", id, "wt", "xml", "fl", "score,val_i"), + reqWithPath("/get", "id", id, "wt", "xml", "fl", "score,val_i"), "count(//doc)=1", "//doc/int[@name='val_i']", "//doc[count(*)=1]"); @@ -280,12 +279,11 @@ public void testFunctionsRTG() { for (String id : Arrays.asList("42", "99")) { for (SolrParams p : Arrays.asList( - params("qt", "/get", "id", id, "wt", "xml", "fl", "log(val_i),abs(val_i)"), - params( - "qt", "/get", "id", id, "wt", "xml", "fl", "log(val_i)", "fl", "abs(val_i)"))) { + params("id", id, "wt", "xml", "fl", "log(val_i),abs(val_i)"), + params("id", id, "wt", "xml", "fl", "log(val_i)", "fl", "abs(val_i)"))) { assertQ( "id=" + id + ", params=" + p, - req(p), + reqWithPath("/get", p), "count(//doc)=1", // true for both these specific docs "//doc/double[@name='log(val_i)'][.='0.0']", @@ -321,7 +319,7 @@ public void testFunctionsAndExplicitRTG() { params("fl", "log(val_i),val_i"), params("fl", "log(val_i)", "fl", "val_i"))) { assertQ( id + " " + p, - req(p, "qt", "/get", "wt", "xml", "id", id), + reqWithPath("/get", p, "wt", "xml", "id", id), "count(//doc)=1", // true for both these specific docs "//doc/double[@name='log(val_i)'][.='0.0']", @@ -377,7 +375,7 @@ public void testFunctionsAndScoreRTG() { params("fl", "score,log(val_i),abs(val_i)"))) { assertQ( "id=" + id + ", p=" + p, - req(p, "qt", "/get", "id", id, "wt", "xml"), + reqWithPath("/get", p, "id", id, "wt", "xml"), "count(//doc)=1", "//doc/double[@name='log(val_i)']", "//doc/float[@name='abs(val_i)'][.='1.0']", @@ -415,7 +413,7 @@ public void testGlobsRTG() { for (String id : Arrays.asList("42", "99")) { assertQ( id + ": fl=val_*", - req("qt", "/get", "id", id, "wt", "xml", "fl", "val_*"), + reqWithPath("/get", "id", id, "wt", "xml", "fl", "val_*"), "count(//doc)=1", "//doc/int[@name='val_i'][.=1]", "//doc[count(*)=1]"); @@ -424,7 +422,7 @@ public void testGlobsRTG() { params("fl", "val_*,subj*,ss*"), params("fl", "val_*", "fl", "subj*,ss*"))) { assertQ( id + ": " + p, - req(p, "qt", "/get", "id", id, "wt", "xml"), + reqWithPath("/get", p, "id", id, "wt", "xml"), "count(//doc)=1", "//doc/int[@name='val_i'][.=1]", "//doc/str[@name='subject']", // value differs between docs @@ -464,7 +462,7 @@ public void testGlobsAndExplicitRTG() { for (String id : Arrays.asList("42", "99")) { assertQ( id + " + fl=val_*,id", - req("qt", "/get", "id", id, "wt", "xml", "fl", "val_*,id"), + reqWithPath("/get", "id", id, "wt", "xml", "fl", "val_*,id"), "count(//doc)=1", "//doc/int[@name='val_i'][.=1]", "//doc/str[@name='id']", @@ -477,7 +475,7 @@ public void testGlobsAndExplicitRTG() { params("fl", "val_*", "fl", "subj*,id"))) { assertQ( id + " + " + p, - req(p, "qt", "/get", "id", id, "wt", "xml"), + reqWithPath("/get", p, "id", id, "wt", "xml"), "count(//doc)=1", "//doc/int[@name='val_i'][.=1]", "//doc/str[@name='subject']", @@ -516,7 +514,7 @@ public void testGlobsAndScoreRTG() { for (String id : Arrays.asList("42", "99")) { assertQ( id + ": fl=val_*,score", - req("qt", "/get", "id", id, "wt", "xml", "fl", "val_*,score"), + reqWithPath("/get", "id", id, "wt", "xml", "fl", "val_*,score"), "count(//doc)=1", "//doc/int[@name='val_i']", "//doc[count(*)=1]"); @@ -527,7 +525,7 @@ public void testGlobsAndScoreRTG() { params("fl", "val_*", "fl", "subj*,score"))) { assertQ( "" + p, - req(p, "qt", "/get", "id", id, "wt", "xml"), + reqWithPath("/get", p, "id", id, "wt", "xml"), "count(//doc)=1", "//doc/int[@name='val_i']", "//doc/str[@name='subject']", @@ -573,7 +571,7 @@ public void testDocIdAugmenterRTG() { for (String id : Arrays.asList("42", "99")) { assertQ( id + ": fl=[docid]", - req("qt", "/get", "id", id, "wt", "xml", "fl", "[docid]"), + reqWithPath("/get", "id", id, "wt", "xml", "fl", "[docid]"), "count(//doc)=1", "//doc/int[@name='[docid]'][.>=-1]", "//doc[count(*)=1]"); @@ -608,7 +606,7 @@ public void testAugmentersRTG() { "abs(val_i)"))) { assertQ( id + ": " + p, - req(p, "qt", "/get", "id", id, "wt", "xml"), + reqWithPath("/get", p, "id", id, "wt", "xml"), "count(//doc)=1", "//doc/int[@name='[docid]'][.>=-1]", "//doc/float[@name='abs(val_i)'][.='1.0']", @@ -666,7 +664,7 @@ public void testAugmentersAndExplicitRTG() { "abs(val_i)"))) { assertQ( id + ": " + p, - req(p, "qt", "/get", "id", id, "wt", "xml"), + reqWithPath("/get", p, "id", id, "wt", "xml"), "count(//doc)=1", "//doc/str[@name='id']", "//doc/int[@name='[docid]'][.>=-1]", @@ -724,8 +722,7 @@ public void testAugmentersAndScoreRTG() { for (String id : Arrays.asList("42", "99")) { assertQ( id, - req( - "qt", + reqWithPath( "/get", "id", id, @@ -756,7 +753,7 @@ public void testAugmentersAndScoreRTG() { assertQ( p.toString(), - req(p, "qt", "/get", "id", id, "wt", "xml"), + reqWithPath("/get", p, "id", id, "wt", "xml"), "//doc/int[@name='[docid]']", // TODO "//doc/float[@name='abs(val_i)'][.='1.0']", "//doc/int[@name='x_alias'][.=10]", @@ -821,7 +818,7 @@ public void testAugmentersGlobsExplicitAndScoreOhMyRTG() { for (SolrParams p : Arrays.asList(singleFl, multiFl)) { assertQ( id + ": " + p, - req(p, "qt", "/get", "id", id, "wt", "xml"), + reqWithPath("/get", p, "id", id, "wt", "xml"), "count(//doc)=1", "//doc/str[@name='id']", "//doc/int[@name='[docid]'][.>=-1]", diff --git a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java index a589eafdf4c..a5109562d0d 100644 --- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java +++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java @@ -357,7 +357,7 @@ public void testUpdatingDocValues() throws Exception { v20, "id", "20", "_version_", v20, "inplace_updatable_float", map("inc", 1)); // RTG before a commit assertJQ( - req("qt", "/get", "id", "20", "fl", "id,inplace_updatable_float,_version_"), + reqWithPath("/get", "id", "20", "fl", "id,inplace_updatable_float,_version_"), "=={'doc':{'id':'20', 'inplace_updatable_float':" + 102.0 + ",'_version_':" + v20 + "}}"); assertU(commit("softCommit", "false")); assertQ( @@ -653,7 +653,7 @@ public void testUpdateTwoDifferentFields() throws Exception { // RTG assertJQ( - req("qt", "/get", "id", "1", "fl", "id,inplace_updatable_float,inplace_updatable_int"), + reqWithPath("/get", "id", "1", "fl", "id,inplace_updatable_float,inplace_updatable_int"), "=={'doc':{'id':'1', 'inplace_updatable_float':" + 202.0 + ",'inplace_updatable_int':" @@ -670,7 +670,7 @@ public void testUpdateWithValueNull() throws Exception { assertQ(req("q", "*:*", "fq", "inplace_updatable_float:[* TO *]"), "//*[@numFound='1']"); // RTG before update assertJQ( - req("qt", "/get", "id", "1", "fl", "id,inplace_updatable_float,title_s"), + reqWithPath("/get", "id", "1", "fl", "id,inplace_updatable_float,title_s"), "=={'doc':{'id':'1', 'inplace_updatable_float':" + 42.0 + ",'title_s':" + "first" + "}}"); // set the value to null @@ -681,7 +681,7 @@ public void testUpdateWithValueNull() throws Exception { assertQ(req("q", "*:*", "fq", "inplace_updatable_float:[* TO *]"), "//*[@numFound='0']"); // after update assertJQ( - req("qt", "/get", "id", "1", "fl", "id,inplace_updatable_float,title_s"), + reqWithPath("/get", "id", "1", "fl", "id,inplace_updatable_float,title_s"), "=={'doc':{'id':'1','title_s':first}}"); } diff --git a/solr/core/src/test/org/apache/solr/update/TestUpdate.java b/solr/core/src/test/org/apache/solr/update/TestUpdate.java index a23e0bad45d..576fbcee26a 100644 --- a/solr/core/src/test/org/apache/solr/update/TestUpdate.java +++ b/solr/core/src/test/org/apache/solr/update/TestUpdate.java @@ -61,7 +61,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,*_i,*_is,copyfield_*"), + reqWithPath("/get", "id", "1", "fl", "id,*_i,*_is,copyfield_*"), "=={'doc':{'id':'1', 'val_i':5, 'val_is':[10,5], 'copyfield_source':['a','b']}}" // real-time get should not return stored copyfield targets ); @@ -70,7 +70,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,*_i,*_is"), + reqWithPath("/get", "id", "1", "fl", "id,*_i,*_is"), "=={'doc':{'id':'1', 'val_i':100, 'val_is':[10,5,-1]}}"); // Do a search to get all stored fields back and make sure that the stored copyfield target only @@ -110,7 +110,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,*_i,*_is"), + reqWithPath("/get", "id", "1", "fl", "id,*_i,*_is"), "=={'doc':{'id':'1', 'val_i':100, 'val_is':[10,5,-1,-100,-200]}}"); // extra field should just be treated as a "set" @@ -118,7 +118,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,*_i,*_is"), + reqWithPath("/get", "id", "1", "fl", "id,*_i,*_is"), "=={'doc':{'id':'1', 'val_i':2, 'val_is':[10,5,-1,-100,-200,-300]}}"); // a null value should be treated as "remove" @@ -126,7 +126,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,*_i,*_is"), + reqWithPath("/get", "id", "1", "fl", "id,*_i,*_is"), "=={'doc':{'id':'1', 'val_is':[10,5,-1,-100,-200,-300,-400]}}"); version = deleteAndGetVersion("1", null); @@ -145,7 +145,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { version = addAndGetVersion(sdoc("id", "1", "val_i", 102, "val_is", map("add", -102)), null); afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,val*"), + reqWithPath("/get", "id", "1", "fl", "id,val*"), "=={'doc':{'id':'1', 'val_i':102, 'val_is':[-102]}}"); version = addAndGetVersion(sdoc("id", "1", "val_i", 5), null); @@ -170,7 +170,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,val*"), + reqWithPath("/get", "id", "1", "fl", "id,val*"), "=={'doc':{'id':'1', 'val_i':5, 'val_is':[1], 'val2_i':1, 'val2_f':1.0, 'val2_d':1.0, 'val2_l':1}}"); version = @@ -192,7 +192,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,val*"), + reqWithPath("/get", "id", "1", "fl", "id,val*"), "=={'doc':{'id':'1', 'val_i':5, 'val_is':[-4], 'val2_i':-4, 'val2_f':-4.0, 'val2_d':-4.0, 'val2_l':-4}}"); version = @@ -214,7 +214,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,val*"), + reqWithPath("/get", "id", "1", "fl", "id,val*"), "=={'doc':{'id':'1', 'val_i':5, 'val_is':[1999999996], 'val2_i':-2000000004, 'val2_f':1.0E20, 'val2_d':-1.2345678901e+100, 'val2_l':4999999996}}"); // remove some fields @@ -229,7 +229,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,val*"), + reqWithPath("/get", "id", "1", "fl", "id,val*"), "=={'doc':{'id':'1', 'val_i':5, 'val2_i':-2000000004, 'val2_d':-1.2345678901e+100, 'val2_l':4999999996}}"); // test that updating a unique id results in failure. @@ -248,7 +248,7 @@ public void doUpdateTest(Callable afterUpdate) throws Exception { afterUpdate.call(); assertJQ( - req("qt", "/get", "id", "1", "fl", "id,val*"), + reqWithPath("/get", "id", "1", "fl", "id,val*"), "=={'doc':{'id':'1', 'val_i':5, 'val2_i':-2000000004, 'val2_d':-1.2345678901e+100, 'val2_l':4999999996}}"); // nothing should have changed - check with a normal query that we didn't create a duplicate diff --git a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java index b953203ca7a..8d3bda2d749 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java @@ -1551,7 +1551,7 @@ public void testFieldsWithDefaultValuesWhenAtomicUpdatesAgainstTlog() { assertU(adoc(sdoc("id", "7", fieldToUpdate, "666"))); assertQ( fieldToUpdate + ": initial RTG", - req("qt", "/get", "id", "7"), + reqWithPath("/get", "id", "7"), "count(//doc)=1", "//doc/str[@name='id'][.='7']", "//doc/int[@name='" + fieldToUpdate + "'][.='666']", @@ -1565,7 +1565,7 @@ public void testFieldsWithDefaultValuesWhenAtomicUpdatesAgainstTlog() { assertU(adoc(sdoc("id", "7", fieldToUpdate, Map.of("inc", -555)))); assertQ( fieldToUpdate + ": RTG after atomic update", - req("qt", "/get", "id", "7"), + reqWithPath("/get", "id", "7"), "count(//doc)=1", "//doc/str[@name='id'][.='7']", "//doc/int[@name='" + fieldToUpdate + "'][.='111']", @@ -1578,7 +1578,7 @@ public void testFieldsWithDefaultValuesWhenAtomicUpdatesAgainstTlog() { assertU(commit()); assertQ( fieldToUpdate + ": post commit RTG", - req("qt", "/get", "id", "7"), + reqWithPath("/get", "id", "7"), "count(//doc)=1", "//doc/str[@name='id'][.='7']", "//doc/int[@name='" + fieldToUpdate + "'][.='111']", @@ -1599,7 +1599,7 @@ public void testAtomicUpdateOfFieldsWithDefaultValue() { assertU(adoc(sdoc("id", "7", fieldToUpdate, Map.of("inc", "666")))); assertQ( fieldToUpdate + ": initial RTG#7", - req("qt", "/get", "id", "7"), + reqWithPath("/get", "id", "7"), "count(//doc)=1", "//doc/str[@name='id'][.='7']", "//doc/int[@name='" + fieldToUpdate + "'][.='708']", @@ -1612,7 +1612,7 @@ public void testAtomicUpdateOfFieldsWithDefaultValue() { assertU(adoc(sdoc("id", "7", fieldToUpdate, Map.of("inc", -555)))); assertQ( fieldToUpdate + ": RTG#7 after atomic update", - req("qt", "/get", "id", "7"), + reqWithPath("/get", "id", "7"), "count(//doc)=1", "//doc/str[@name='id'][.='7']", "//doc/int[@name='" + fieldToUpdate + "'][.='153']", @@ -1626,7 +1626,7 @@ public void testAtomicUpdateOfFieldsWithDefaultValue() { assertU(adoc(sdoc("id", "8", fieldToUpdate, Map.of("set", "666")))); assertQ( fieldToUpdate + ": initial RTG#8", - req("qt", "/get", "id", "8"), + reqWithPath("/get", "id", "8"), "count(//doc)=1", "//doc/str[@name='id'][.='8']", "//doc/int[@name='" + fieldToUpdate + "'][.='666']", @@ -1639,7 +1639,7 @@ public void testAtomicUpdateOfFieldsWithDefaultValue() { assertU(adoc(sdoc("id", "8", fieldToUpdate, Map.of("inc", -555)))); assertQ( fieldToUpdate + ": RTG after atomic update", - req("qt", "/get", "id", "8"), + reqWithPath("/get", "id", "8"), "count(//doc)=1", "//doc/str[@name='id'][.='8']", "//doc/int[@name='" + fieldToUpdate + "'][.='111']", @@ -1653,7 +1653,7 @@ public void testAtomicUpdateOfFieldsWithDefaultValue() { assertQ( fieldToUpdate + ": doc7 post commit RTG", - req("qt", "/get", "id", "7"), + reqWithPath("/get", "id", "7"), "count(//doc)=1", "//doc/str[@name='id'][.='7']", "//doc/int[@name='" + fieldToUpdate + "'][.='153']", @@ -1664,7 +1664,7 @@ public void testAtomicUpdateOfFieldsWithDefaultValue() { "//doc/arr[@name='multiDefault']/str[.='muLti-Default']"); assertQ( fieldToUpdate + ": doc8 post commit RTG", - req("qt", "/get", "id", "8"), + reqWithPath("/get", "id", "8"), "count(//doc)=1", "//doc/str[@name='id'][.='8']", "//doc/int[@name='" + fieldToUpdate + "'][.='111']", diff --git a/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java b/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java index ec4f00775c2..d3f75dbe924 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java @@ -508,7 +508,7 @@ public void testBlockAtomicAdd() throws Exception { addAndGetVersion(doc, null); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, child2, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, child2, [child]"), "=={\"doc\":{'id':\"1\"" + ", cat_ss:[\"aaa\",\"ccc\",\"bbb\"], child2:[{\"id\":\"3\", \"cat_ss\": [\"child\"]}]," + "child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}]" @@ -521,7 +521,7 @@ public void testBlockAtomicAdd() throws Exception { // this requires ChildDocTransformer to get the whole block, since the document is retrieved // using an index lookup assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, child2, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, child2, [child]"), "=={\"doc\":{'id':\"1\"" + ", cat_ss:[\"aaa\",\"ccc\",\"bbb\"], child2:[{\"id\":\"3\", \"cat_ss\": [\"child\"]}]," + "child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}]" @@ -538,14 +538,14 @@ public void testBlockAtomicAdd() throws Exception { addAndGetVersion(doc, null); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, child2, child3, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, child2, child3, [child]"), "=={'doc':{'id':'1'" + ", cat_ss:[\"aaa\",\"ccc\",\"bbb\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"], child3:[{\"id\":\"4\",\"cat_ss\":[\"grandChild\"]}]}]," + "child2:[{\"id\":\"3\", \"cat_ss\": [\"child\"]}]" + " }}"); assertJQ( - req("qt", "/get", "id", "2", "fl", "id, cat_ss, child, child3, [child]"), + reqWithPath("/get", "id", "2", "fl", "id, cat_ss, child, child3, [child]"), "=={'doc':{\"id\":\"2\",\"cat_ss\":[\"child\"], child3:[{\"id\":\"4\",\"cat_ss\":[\"grandChild\"]}]}" + " }}"); @@ -563,14 +563,14 @@ public void testBlockAtomicAdd() throws Exception { addAndGetVersion(doc, null); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, child2, child3, child4, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, child2, child3, child4, [child]"), "=={'doc':{'id':'1'" + ", cat_ss:[\"aaa\",\"ccc\",\"bbb\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"], child3:[{\"id\":\"4\",\"cat_ss\":[\"grandChild\"]," + " child4:[{\"id\":\"5\",\"cat_ss\":[\"greatGrandChild\"]}]}]}], child2:[{\"id\":\"3\", \"cat_ss\": [\"child\"]}]" + " }}"); assertJQ( - req("qt", "/get", "id", "4", "fl", "id, cat_ss, child4, [child]"), + reqWithPath("/get", "id", "4", "fl", "id, cat_ss, child4, [child]"), "=={'doc':{\"id\":\"4\",\"cat_ss\":[\"grandChild\"], child4:[{\"id\":\"5\",\"cat_ss\":[\"greatGrandChild\"]}]}" + " }}"); @@ -590,7 +590,7 @@ public void testBlockAtomicAdd() throws Exception { assertU(commit()); assertJQ( - req("qt", "/get", "id", "4", "fl", "id, cat_ss, child4, [child]"), + reqWithPath("/get", "id", "4", "fl", "id, cat_ss, child4, [child]"), "=={'doc':{\"id\":\"4\",\"cat_ss\":[\"grandChild\"], child4:[{\"id\":\"5\",\"cat_ss\":[\"greatGrandChild\"]}," + "{\"id\":\"6\", \"cat_ss\":[\"greatGrandChild\"]}]}" + " }}"); @@ -668,7 +668,7 @@ public void testBlockAtomicSet() throws Exception { assertJQ(req("q", "id:1"), "/response/numFound==1"); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\"" + ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}]" + " }}"); @@ -676,7 +676,7 @@ public void testBlockAtomicSet() throws Exception { assertU(commit()); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\"" + ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}]" + " }}"); @@ -694,7 +694,7 @@ public void testBlockAtomicSet() throws Exception { addAndGetVersion(doc, null); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\"" + ", cat_ss:[\"aaa\",\"bbb\"], child1:{\"id\":\"3\",\"cat_ss\":[\"child\"]}" + " }}"); @@ -705,7 +705,7 @@ public void testBlockAtomicSet() throws Exception { // rather than the transaction log. this requires ChildDocTransformer to get the whole block, // since the document is retrieved using an index lookup assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={'doc':{'id':'1'" + ", cat_ss:[\"aaa\",\"bbb\"], child1:{\"id\":\"3\",\"cat_ss\":[\"child\"]}" + " }}"); @@ -715,13 +715,13 @@ public void testBlockAtomicSet() throws Exception { addAndGetVersion(doc, null); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, child2, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, child2, [child]"), "=={'doc':{'id':'1'" + ", cat_ss:[\"aaa\",\"bbb\"], child1:{\"id\":\"3\",\"cat_ss\":[\"child\"], child2:{\"id\":\"4\",\"cat_ss\":[\"child\"]}}" + " }}"); assertJQ( - req("qt", "/get", "id", "3", "fl", "id, cat_ss, child, child2, [child]"), + reqWithPath("/get", "id", "3", "fl", "id, cat_ss, child, child2, [child]"), "=={'doc':{\"id\":\"3\",\"cat_ss\":[\"child\"], child2:{\"id\":\"4\",\"cat_ss\":[\"child\"]}}" + " }}"); @@ -811,7 +811,7 @@ public void testBlockAtomicRemove() throws Exception { assertJQ(req("q", "id:1"), "/response/numFound==1"); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\"" + ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}, {\"id\":\"3\",\"cat_ss\":[\"child\"]}]" + " }}"); @@ -819,7 +819,7 @@ public void testBlockAtomicRemove() throws Exception { assertU(commit()); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\"" + ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}, {\"id\":\"3\",\"cat_ss\":[\"child\"]}]" + " }}"); @@ -828,7 +828,7 @@ public void testBlockAtomicRemove() throws Exception { addAndGetVersion(doc, null); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\"" + ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}]" + " }}"); @@ -839,7 +839,7 @@ public void testBlockAtomicRemove() throws Exception { // rather than the transaction log. this requires ChildDocTransformer to get the whole block, // since the document is retrieved using an index lookup assertJQ( - req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={'doc':{'id':'1'" + ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}]" + " }}"); @@ -905,14 +905,14 @@ private void testBlockAtomicSetToNullOrEmpty(boolean empty) throws Exception { assertJQ(req("q", "id:1"), "/response/numFound==1"); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, latlon, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, latlon, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\", \"latlon\":\"0,0\"" + ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}, {\"id\":\"3\",\"cat_ss\":[\"child\"]}]}}"); assertU(commit()); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, latlon, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, latlon, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\", \"latlon\":\"0,0\"" + ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}, {\"id\":\"3\",\"cat_ss\":[\"child\"]}]}}"); @@ -922,7 +922,7 @@ private void testBlockAtomicSetToNullOrEmpty(boolean empty) throws Exception { addAndGetVersion(doc, null); assertJQ( - req("qt", "/get", "id", "1", "fl", "id, latlon, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, latlon, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\", \"latlon\":\"0,0\", cat_ss:[\"aaa\",\"ccc\"]}}"); assertU(commit()); @@ -931,7 +931,7 @@ private void testBlockAtomicSetToNullOrEmpty(boolean empty) throws Exception { // rather than the transaction log. this requires ChildDocTransformer to get the whole block, // since the document is retrieved using an index lookup assertJQ( - req("qt", "/get", "id", "1", "fl", "id, latlon, cat_ss, child1, [child]"), + reqWithPath("/get", "id", "1", "fl", "id, latlon, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\", \"latlon\":\"0,0\", cat_ss:[\"aaa\",\"ccc\"]}}"); // ensure the whole block has been committed correctly to the index. diff --git a/solr/core/src/test/org/apache/solr/update/processor/TestDocBasedVersionConstraints.java b/solr/core/src/test/org/apache/solr/update/processor/TestDocBasedVersionConstraints.java index ca28d1333be..875176a09df 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/TestDocBasedVersionConstraints.java +++ b/solr/core/src/test/org/apache/solr/update/processor/TestDocBasedVersionConstraints.java @@ -60,22 +60,22 @@ public void testSimpleUpdates() throws Exception { assertU(adoc("id", "aaa", "name", "a2", "my_version_l", "1002")); assertU(commit()); assertU(adoc("id", "aaa", "name", "XX", "my_version_l", "1")); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:XX"), "/response/numFound==0"); assertJQ(req("q", "+id:aaa +name:a2"), "/response/numFound==1"); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); // skip low version against uncommitted data from updateLog assertU(adoc("id", "aaa", "name", "a3", "my_version_l", "1003")); assertU(adoc("id", "aaa", "name", "XX", "my_version_l", "7")); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a3'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a3'}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:XX"), "/response/numFound==0"); assertJQ(req("q", "+id:aaa +name:a3"), "/response/numFound==1"); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a3'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a3'}}"); // interleave updates to multiple docs using same versions for (long ver = 1010; ver < 1020; ver++) { @@ -86,7 +86,7 @@ public void testSimpleUpdates() throws Exception { for (String id : new String[] {"aaa", "bbb", "ccc", "ddd"}) { assertU(adoc("id", id, "name", "XX", "my_version_l", "10")); assertJQ( - req("qt", "/get", "id", id, "fl", "my_version_l"), + reqWithPath("/get", "id", id, "fl", "my_version_l"), "=={'doc':{'my_version_l':" + 1019 + "}}"); } assertU(commit()); @@ -96,7 +96,7 @@ public void testSimpleUpdates() throws Exception { assertJQ(req("q", "+name:XX +id:" + id), "/response/numFound==0"); assertJQ(req("q", "+id:" + id + " +my_version_l:1019"), "/response/numFound==1"); assertJQ( - req("qt", "/get", "id", id, "fl", "my_version_l"), + reqWithPath("/get", "id", id, "fl", "my_version_l"), "=={'doc':{'my_version_l':" + 1019 + "}}"); } } @@ -109,42 +109,42 @@ public void testSimpleDeletes() throws Exception { assertU(adoc("id", "aaa", "name", "a2", "my_version_l", "1002")); assertU(commit()); deleteAndGetVersion("aaa", params("del_version", "7")); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:a2"), "/response/numFound==1"); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); // skip low version delete against uncommitted doc from updateLog assertU(adoc("id", "aaa", "name", "a3", "my_version_l", "1003")); deleteAndGetVersion("aaa", params("del_version", "8")); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a3'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a3'}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:a3"), "/response/numFound==1"); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a3'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a3'}}"); // skip low version add against uncommitted "delete" from updateLog deleteAndGetVersion("aaa", params("del_version", "1010")); assertU(adoc("id", "aaa", "name", "XX", "my_version_l", "22")); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:XX"), "/response/numFound==0"); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}"); // skip low version add against committed "delete" // (delete was already done & committed above) assertU(adoc("id", "aaa", "name", "XX", "my_version_l", "23")); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:XX"), "/response/numFound==0"); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}"); } /** @@ -162,13 +162,13 @@ public void testFloatVersionField() throws Exception { jsonAdd(sdoc("id", "aaa", "name", "XX", "my_version_f", "4.2")), params("update.chain", "external-version-float")); assertU(commit()); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a1'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a1'}}"); deleteAndGetVersion( "aaa", params( "del_version", "7", "update.chain", "external-version-float")); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a1'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a1'}}"); assertU(commit()); // skip low version delete against uncommitted doc from updateLog @@ -180,11 +180,11 @@ public void testFloatVersionField() throws Exception { params( "del_version", "8", "update.chain", "external-version-float")); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:a2"), "/response/numFound==1"); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); // skip low version add against uncommitted "delete" from updateLog deleteAndGetVersion( @@ -196,12 +196,13 @@ public void testFloatVersionField() throws Exception { jsonAdd(sdoc("id", "aaa", "name", "XX", "my_version_f", "10.05")), params("update.chain", "external-version-float")); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_f"), "=={'doc':{'my_version_f':10.10}}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_f"), + "=={'doc':{'my_version_f':10.10}}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:XX"), "/response/numFound==0"); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_f"), "=={'doc':{'my_version_f':10.10}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_f"), "=={'doc':{'my_version_f':10.10}}"); // skip low version add against committed "delete" // (delete was already done & committed above) @@ -209,12 +210,13 @@ public void testFloatVersionField() throws Exception { jsonAdd(sdoc("id", "aaa", "name", "XX", "my_version_f", "10.09")), params("update.chain", "external-version-float")); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_f"), "=={'doc':{'my_version_f':10.10}}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_f"), + "=={'doc':{'my_version_f':10.10}}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:XX"), "/response/numFound==0"); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_f"), "=={'doc':{'my_version_f':10.10}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_f"), "=={'doc':{'my_version_f':10.10}}"); } public void testFailOnOldVersion() throws Exception { @@ -236,7 +238,7 @@ public void testFailOnOldVersion() throws Exception { assertEquals(409, ex.code()); assertU(commit()); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a1'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a1'}}"); ex = expectThrows( @@ -247,7 +249,7 @@ public void testFailOnOldVersion() throws Exception { }); assertEquals(409, ex.code()); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a1'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a1'}}"); assertU(commit()); // fail low version delete against uncommitted doc from updateLog @@ -263,11 +265,11 @@ public void testFailOnOldVersion() throws Exception { }); assertEquals(409, ex.code()); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:a2"), "/response/numFound==1"); - assertJQ(req("qt", "/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); + assertJQ(reqWithPath("/get", "id", "aaa", "fl", "name"), "=={'doc':{'name':'a2'}}"); // fail low version add against uncommitted "delete" from updateLog deleteAndGetVersion( @@ -286,12 +288,12 @@ public void testFailOnOldVersion() throws Exception { assertEquals(409, ex.code()); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:XX"), "/response/numFound==0"); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}"); // fail low version add against committed "delete" // (delete was already done & committed above) @@ -306,12 +308,12 @@ public void testFailOnOldVersion() throws Exception { assertEquals(409, ex.code()); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}}"); assertU(commit()); assertJQ(req("q", "+id:aaa"), "/response/numFound==1"); assertJQ(req("q", "+id:aaa +name:XX"), "/response/numFound==0"); assertJQ( - req("qt", "/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}"); + reqWithPath("/get", "id", "aaa", "fl", "my_version_l"), "=={'doc':{'my_version_l':1010}}"); } // Test multiple versions, that it has to be greater than my_version_l and my_version_f @@ -589,7 +591,7 @@ public void testConcurrentAdds() throws Exception { + (!winnerIsDeleted ? ",'name':'name" + id + "_" + winner + "'}" : "}"); assertJQ( - req("qt", "/get", "id", "" + id, "fl", "id,name,my_version_l"), + reqWithPath("/get", "id", "" + id, "fl", "id,name,my_version_l"), "=={'doc':" + expectedDoc + "}"); assertU(commit()); assertJQ( @@ -638,10 +640,10 @@ public void testMissingVersionOnOldDocs() throws Exception { assertU(commit()); assertJQ(req("q", "*:*"), "/response/numFound==2"); assertJQ( - req("qt", "/get", "id", "a", "fl", "id,my_version_l"), + reqWithPath("/get", "id", "a", "fl", "id,my_version_l"), "=={'doc':{'id':'a', 'my_version_l':3}}"); // version changed to 3 assertJQ( - req("qt", "/get", "id", "b", "fl", "id,my_version_l"), + reqWithPath("/get", "id", "b", "fl", "id,my_version_l"), "=={'doc':{'id':'b'}}"); // no version, because update failed // Try to update again using the external version enforcement, but allowing old docs to not have @@ -657,10 +659,10 @@ public void testMissingVersionOnOldDocs() throws Exception { assertU(commit()); assertJQ(req("q", "*:*"), "/response/numFound==2"); assertJQ( - req("qt", "/get", "id", "a", "fl", "id,my_version_l"), + reqWithPath("/get", "id", "a", "fl", "id,my_version_l"), "=={'doc':{'id':'a', 'my_version_l':3}}"); assertJQ( - req("qt", "/get", "id", "b", "fl", "id,my_version_l"), + reqWithPath("/get", "id", "b", "fl", "id,my_version_l"), "=={'doc':{'id':'b', 'my_version_l':1}}"); }