You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2016/01/20 13:43:25 UTC
svn commit: r1725708 - in /lucene/dev/trunk/solr: ./
core/src/java/org/apache/solr/handler/ core/src/java/org/apache/solr/search/
solrj/src/java/org/apache/solr/common/params/
solrj/src/test/org/apache/solr/common/params/
Author: cpoerschke
Date: Wed Jan 20 12:43:25 2016
New Revision: 1725708
URL: http://svn.apache.org/viewvc?rev=1725708&view=rev
Log:
SOLR-8565: add & use CommonParams.(ROWS|START)_DEFAULT constants, add CommonParamsTest
Added:
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/params/CommonParamsTest.java (with props)
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/TermsParams.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1725708&r1=1725707&r2=1725708&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Wed Jan 20 12:43:25 2016
@@ -556,6 +556,8 @@ Other Changes
* SOLR-8566: various initialCapacity tweaks (Fix Versions: trunk 5.5)
(Christine Poerschke)
+* SOLR-8565: add & use CommonParams.(ROWS|START)_DEFAULT constants (Christine Poerschke)
+
================== 5.4.1 ==================
Bug Fixes
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java?rev=1725708&r1=1725707&r2=1725708&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java Wed Jan 20 12:43:25 2016
@@ -166,8 +166,8 @@ public class MoreLikeThisHandler extends
}
}
- int start = params.getInt(CommonParams.START, 0);
- int rows = params.getInt(CommonParams.ROWS, 10);
+ int start = params.getInt(CommonParams.START, CommonParams.START_DEFAULT);
+ int rows = params.getInt(CommonParams.ROWS, CommonParams.ROWS_DEFAULT);
// Find documents MoreLikeThis - either with a reader or a query
// --------------------------------------------------------------------------------
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java?rev=1725708&r1=1725707&r2=1725708&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java Wed Jan 20 12:43:25 2016
@@ -241,8 +241,8 @@ public abstract class QParser {
}
}
- int start = startS != null ? Integer.parseInt(startS) : 0;
- int rows = rowsS != null ? Integer.parseInt(rowsS) : 10;
+ int start = startS != null ? Integer.parseInt(startS) : CommonParams.START_DEFAULT;
+ int rows = rowsS != null ? Integer.parseInt(rowsS) : CommonParams.ROWS_DEFAULT;
SortSpec sort = SortSpecParsing.parseSortSpec(sortStr, req);
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java?rev=1725708&r1=1725707&r2=1725708&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java Wed Jan 20 12:43:25 2016
@@ -90,8 +90,8 @@ public class ReRankQParserPlugin extends
double reRankWeight = localParams.getDouble("reRankWeight",2.0d);
- int start = params.getInt(CommonParams.START,0);
- int rows = params.getInt(CommonParams.ROWS,10);
+ int start = params.getInt(CommonParams.START,CommonParams.START_DEFAULT);
+ int rows = params.getInt(CommonParams.ROWS,CommonParams.ROWS_DEFAULT);
int length = start+rows;
return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight, length);
}
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java?rev=1725708&r1=1725707&r2=1725708&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java Wed Jan 20 12:43:25 2016
@@ -62,9 +62,11 @@ public interface CommonParams {
/** zero based offset of matching documents to retrieve */
public static final String START ="start";
+ public static final int START_DEFAULT = 0;
/** number of documents to return starting at "start" */
public static final String ROWS ="rows";
+ public static final int ROWS_DEFAULT = 10;
// SOLR-4228 start
/** handler value for SolrPing */
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/TermsParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/TermsParams.java?rev=1725708&r1=1725707&r2=1725708&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/TermsParams.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/TermsParams.java Wed Jan 20 12:43:25 2016
@@ -63,7 +63,7 @@ public interface TermsParams {
public static final String TERMS_LOWER_INCLUSIVE = TERMS_PREFIX + "lower.incl";
/**
- * Optional. The number of results to return. If not specified, looks for {@link org.apache.solr.common.params.CommonParams#ROWS}. If that's not specified, uses 10.
+ * Optional. The number of results to return. If not specified, looks for {@link org.apache.solr.common.params.CommonParams#ROWS}. If that's not specified, uses {@link org.apache.solr.common.params.CommonParams#ROWS_DEFAULT}.
*/
public static final String TERMS_LIMIT = TERMS_PREFIX + "limit";
Added: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/params/CommonParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/params/CommonParamsTest.java?rev=1725708&view=auto
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/params/CommonParamsTest.java (added)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/params/CommonParamsTest.java Wed Jan 20 12:43:25 2016
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+import org.apache.lucene.util.LuceneTestCase;
+
+/**
+ * Unit test for {@link CommonParams}
+ *
+ * This class tests backwards compatibility of CommonParams parameter constants.
+ * If someone accidentally changes those constants then this test will flag that up.
+ */
+public class CommonParamsTest extends LuceneTestCase
+{
+ public void testStart() { assertEquals(CommonParams.START, "start"); }
+ public void testStartDefault() { assertEquals(CommonParams.START_DEFAULT, 0); }
+
+ public void testRows() { assertEquals(CommonParams.ROWS, "rows"); }
+ public void testRowsDefault() { assertEquals(CommonParams.ROWS_DEFAULT, 10); }
+}