lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cpoersc...@apache.org
Subject lucene-solr git commit: SOLR-8600: add & use ReRankQParserPlugin parameter [default] constants, changed ReRankQuery.toString to use StringBuilder.
Date Mon, 01 Feb 2016 12:01:04 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 15fed60b0 -> 8e27c14ae


SOLR-8600: add & use ReRankQParserPlugin parameter [default] constants, changed ReRankQuery.toString
to use StringBuilder.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8e27c14a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8e27c14a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8e27c14a

Branch: refs/heads/master
Commit: 8e27c14aeda817df4e6a6394595104a47f6f8fac
Parents: 15fed60
Author: Christine Poerschke <cpoerschke@apache.org>
Authored: Mon Feb 1 12:00:39 2016 +0000
Committer: Christine Poerschke <cpoerschke@apache.org>
Committed: Mon Feb 1 12:00:39 2016 +0000

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  3 +
 .../apache/solr/search/ReRankQParserPlugin.java | 27 ++++++---
 .../apache/solr/search/QueryEqualityTest.java   | 13 ++--
 .../solr/search/TestReRankQParserPlugin.java    | 63 ++++++++++++--------
 4 files changed, 67 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8e27c14a/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index adfc8d7..9b08555 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -585,6 +585,9 @@ Other Changes
 
 * SOLR-7968: Make QueryComponent more extensible. (Markus Jelsma via David Smiley)
 
+* SOLR-8600: add & use ReRankQParserPlugin parameter [default] constants,
+  changed ReRankQuery.toString to use StringBuilder. (Christine Poerschke)
+
 ==================  5.4.1 ==================
 
 Bug Fixes

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8e27c14a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
index 2b23d53..21cca3e 100644
--- a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
@@ -64,6 +64,14 @@ public class ReRankQParserPlugin extends QParserPlugin {
   public static final String NAME = "rerank";
   private static Query defaultQuery = new MatchAllDocsQuery();
 
+  public static final String RERANK_QUERY = "reRankQuery";
+
+  public static final String RERANK_DOCS = "reRankDocs";
+  public static final int RERANK_DOCS_DEFAULT = 200;
+
+  public static final String RERANK_WEIGHT = "reRankWeight";
+  public static final double RERANK_WEIGHT_DEFAULT = 2.0d;
+
   public QParser createParser(String query, SolrParams localParams, SolrParams params, SolrQueryRequest
req) {
     return new ReRankQParser(query, localParams, params, req);
   }
@@ -75,17 +83,17 @@ public class ReRankQParserPlugin extends QParserPlugin {
     }
 
     public Query parse() throws SyntaxError {
-      String reRankQueryString = localParams.get("reRankQuery");
+      String reRankQueryString = localParams.get(RERANK_QUERY);
       if (reRankQueryString == null || reRankQueryString.trim().length() == 0)  {
-        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "reRankQuery parameter
is mandatory");
+        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, RERANK_QUERY+" parameter
is mandatory");
       }
       QParser reRankParser = QParser.getParser(reRankQueryString, null, req);
       Query reRankQuery = reRankParser.parse();
 
-      int reRankDocs  = localParams.getInt("reRankDocs", 200);
+      int reRankDocs  = localParams.getInt(RERANK_DOCS, RERANK_DOCS_DEFAULT);
       reRankDocs = Math.max(1, reRankDocs); //
 
-      double reRankWeight = localParams.getDouble("reRankWeight",2.0d);
+      double reRankWeight = localParams.getDouble(RERANK_WEIGHT, RERANK_WEIGHT_DEFAULT);
 
       int start = params.getInt(CommonParams.START,CommonParams.START_DEFAULT);
       int rows = params.getInt(CommonParams.ROWS,CommonParams.ROWS_DEFAULT);
@@ -150,10 +158,13 @@ public class ReRankQParserPlugin extends QParserPlugin {
 
     @Override
     public String toString(String s) {
-      return "{!rerank mainQuery='"+mainQuery.toString()+
-             "' reRankQuery='"+reRankQuery.toString()+
-             "' reRankDocs="+reRankDocs+
-             " reRankWeight="+reRankWeight+"}";
+      final StringBuilder sb = new StringBuilder(100); // default initialCapacity of 16 won't
be enough
+      sb.append("{!").append(NAME);
+      sb.append(" mainQuery='").append(mainQuery.toString()).append("' ");
+      sb.append(RERANK_QUERY).append("='").append(reRankQuery.toString()).append("' ");
+      sb.append(RERANK_DOCS).append('=').append(reRankDocs).append(' ');
+      sb.append(RERANK_WEIGHT).append('=').append(reRankWeight).append('}');
+      return sb.toString();
     }
 
     public Query rewrite(IndexReader reader) throws IOException {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8e27c14a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
index 75ce44c..08fa329 100644
--- a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
+++ b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
@@ -124,6 +124,7 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
   }
 
   public void testReRankQuery() throws Exception {
+    final String defType = ReRankQParserPlugin.NAME;
     SolrQueryRequest req = req("q", "*:*",
                                "rqq", "{!edismax}hello",
                                "rdocs", "20",
@@ -131,9 +132,9 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
                                "rows", "10",
                                "start", "0");
     try {
-      assertQueryEquals("rerank", req,
-          "{!rerank reRankQuery=$rqq reRankDocs=$rdocs reRankWeight=$rweight}",
-          "{!rerank reRankQuery=$rqq reRankDocs=20 reRankWeight=2}");
+      assertQueryEquals(defType, req,
+          "{!"+defType+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq "+ReRankQParserPlugin.RERANK_DOCS+"=$rdocs
"+ReRankQParserPlugin.RERANK_WEIGHT+"=$rweight}",
+          "{!"+defType+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq "+ReRankQParserPlugin.RERANK_DOCS+"=20
"+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
 
     } finally {
       req.close();
@@ -147,9 +148,9 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
         "rows", "100",
         "start", "50");
     try {
-      assertQueryEquals("rerank", req,
-          "{!rerank mainQuery=$qq reRankQuery=$rqq reRankDocs=$rdocs reRankWeight=$rweight}",
-          "{!rerank mainQuery=$qq reRankQuery=$rqq reRankDocs=20 reRankWeight=2}");
+      assertQueryEquals(defType, req,
+          "{!"+defType+" mainQuery=$qq "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq "+ReRankQParserPlugin.RERANK_DOCS+"=$rdocs
"+ReRankQParserPlugin.RERANK_WEIGHT+"=$rweight}",
+          "{!"+defType+" mainQuery=$qq "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq "+ReRankQParserPlugin.RERANK_DOCS+"=20
"+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
 
     } finally {
       req.close();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8e27c14a/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
----------------------------------------------------------------------
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 40c60c8..9efbad8 100644
--- a/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
@@ -45,6 +45,19 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
   }
 
   @Test
+  public void testReRankQParserPluginConstants() throws Exception {
+    assertEquals(ReRankQParserPlugin.NAME, "rerank");
+
+    assertEquals(ReRankQParserPlugin.RERANK_QUERY, "reRankQuery");
+
+    assertEquals(ReRankQParserPlugin.RERANK_DOCS, "reRankDocs");
+    assertEquals(ReRankQParserPlugin.RERANK_DOCS_DEFAULT, 200);
+
+    assertEquals(ReRankQParserPlugin.RERANK_WEIGHT, "reRankWeight");
+    assertEquals(ReRankQParserPlugin.RERANK_WEIGHT_DEFAULT, 2.0d, 0.0d);
+  }
+
+  @Test
   public void testReRankQueries() throws Exception {
 
     assertU(delQ("*:*"));
@@ -73,7 +86,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
 
     ModifiableSolrParams params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=200}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=200}");
     params.add("q", "term_s:YYYY");
     params.add("rqq", "{!edismax bf=$bff}*:*");
     params.add("bff", "field(test_ti)");
@@ -89,7 +102,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
     );
 
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "{!edismax bq=$bqq2}*:*");
@@ -109,7 +122,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test with sort by score.
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "{!edismax bq=$bqq2}*:*");
@@ -130,7 +143,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test with compound sort.
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "{!edismax bq=$bqq2}*:*");
@@ -152,7 +165,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test with elevation
 
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6 reRankWeight=50}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6 "+ReRankQParserPlugin.RERANK_WEIGHT+"=50}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "{!edismax bq=$bqq2}*:*");
@@ -175,7 +188,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test TermQuery rqq
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "test_ti:50^1000");
@@ -195,7 +208,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test Elevation
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "test_ti:50^1000");
@@ -217,7 +230,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test Elevation swapped
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "test_ti:50^1000");
@@ -240,7 +253,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
 
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=4 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=4 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "test_ti:50^1000");
@@ -261,7 +274,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test Elevation with start beyond the rerank docs
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=3 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=3 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "test_ti:50^1000");
@@ -278,7 +291,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test Elevation with zero results
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=3 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=3 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}nada");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "test_ti:50^1000");
@@ -294,7 +307,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Pass in reRankDocs lower then the length being collected.
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=1 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=1 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "test_ti:50^1000");
@@ -312,7 +325,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
     );
 
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=0 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=0 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "test_ti:50^1000");
@@ -330,7 +343,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
     );
 
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=2 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=2 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "test_ti:4^1000");
@@ -349,7 +362,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test reRankWeight of 0, reranking will have no effect.
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6 reRankWeight=0}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6 "+ReRankQParserPlugin.RERANK_WEIGHT+"=0}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "test_ti:50^1000");
@@ -374,7 +387,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test range query
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6}");
     params.add("q", "test_ti:[0 TO 2000]");
     params.add("rqq", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("fl", "id,score");
@@ -400,7 +413,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Run same query and see if it was cached. This tests the query result cache hit with
rewritten queries
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6}");
     params.add("q", "test_ti:[0 TO 2000]");
     params.add("rqq", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("fl", "id,score");
@@ -424,7 +437,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test range query embedded in larger query
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6}");
     // function query for predictible scores (relative to id) independent of similarity
     params.add("q", "{!func}id");
     // constant score for each clause (unique per doc) for predictible scores independent
of similarity
@@ -446,7 +459,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test with start beyond reRankDocs
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=3 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=3 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60");
     params.add("rqq", "id:1^1000");
     params.add("fl", "id,score");
@@ -462,7 +475,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
     //Test ReRankDocs > docs returned
 
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=6 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=6 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50");
     params.add("rqq", "id:1^1000");
     params.add("fl", "id,score");
@@ -477,7 +490,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test with zero results
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=3 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=3 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "term_s:NNNN");
     params.add("rqq", "id:1^1000");
     params.add("fl", "id,score");
@@ -531,7 +544,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
 
     ModifiableSolrParams params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=11 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=11 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60 id:7^70 id:8^80 id:9^90
id:10^100 id:11^110");
     params.add("rqq", "test_ti:50^1000");
@@ -546,7 +559,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     //Test Elevation
     params = new ModifiableSolrParams();
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=11 reRankWeight=2}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=11 "+ReRankQParserPlugin.RERANK_WEIGHT+"=2}");
     params.add("q", "{!edismax bq=$bqq1}*:*");
     params.add("bqq1", "id:1^10 id:2^20 id:3^30 id:4^40 id:5^50 id:6^60 id:7^70 id:8^80 id:9^90
id:10^100 id:11^110");
     params.add("rqq", "test_ti:50^1000");
@@ -576,14 +589,14 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
 
     ModifiableSolrParams params = new ModifiableSolrParams();
 
-    params.add("rq", "{!rerank reRankQuery=$rqq reRankDocs=200}");
+    params.add("rq", "{!"+ReRankQParserPlugin.NAME+" "+ReRankQParserPlugin.RERANK_QUERY+"=$rqq
"+ReRankQParserPlugin.RERANK_DOCS+"=200}");
     params.add("q", "term_s:YYYY");
     params.add("start", "0");
     params.add("rows", "2");
 
     try {
       h.query(req(params));
-      fail("A syntax error should be thrown when reRankQuery parameter is not specified");
+      fail("A syntax error should be thrown when "+ReRankQParserPlugin.RERANK_QUERY+" parameter
is not specified");
     } catch (SolrException e) {
       assertTrue(e.code() == SolrException.ErrorCode.BAD_REQUEST.code);
     }


Mime
View raw message